akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#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 <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>
#include <sys/time.h>
#include <fstream>
#include <iomanip>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define REP(i,n)  FOR(i,0,n)
#define each(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define deb(x) cerr << #x << " = " << (x) << " , ";
#define debl cerr << " (L" << __LINE__ << ")"<< endl;
#define sz(s) (int)((s).size())


#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(x,y) make_pair((x),(y))

double pi=3.14159265358979323846;

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

template<typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& z){
	os << "[ ";
	REP(i,z.size())os << z[i] << ", " ;
	return ( os << "]" << endl);
}

template<typename T> std::ostream& operator<<(std::ostream& os, const set<T>& z){
	os << "set( ";
	EACH(p,z)os << (*p) << ", " ;
	return ( os << ")" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const map<T,U>& z){
	os << "{ ";
	EACH(p,z)os << (p->first) << ": " << (p->second) << ", " ;
	return ( os << "}" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const pair<T,U>& z){
	return ( os << "(" << z.first << ", " << z.second << ",)" );
}

double get_time(){
	struct timeval tv;
	gettimeofday(&tv, NULL);
	return tv.tv_sec + tv.tv_usec*1e-6;
}

typedef unsigned int uint32_t;
struct RND{
	uint32_t x;
	uint32_t y;
	uint32_t z;
	uint32_t w;
	RND(){
		x=123456789;
		y=362436069;
		z=521288629;
		w=88675123;
	}
	void init(int seed){
		x=123456789;
		y=362436069;
		z=521288629;
		w=seed+100;
		REP(i,10)get();
	}
	uint32_t get(){
		uint32_t t;
		t=x^(x<<11);
		x=y;y=z;z=w;
		w=(w^(w>>19))^(t^(t>>8));
		return w;
	}
};
RND rnd;

ll double_to_ll(double d){
	if(d>0)return d+0.5;
	return d-0.5;
}

void _main(istream &inp){
	ll A,B,C;
	inp >> A >> B >>C;
	if(A%2==0 || B%2==0 || C%2==0){
		cout << 0;
		return;
	}
	cout << min(A*B, min(B*C, A*C));

}

int main(){
	if(0){
		ifstream ifs("test.txt");
		_main(ifs);
	}
	else{
		_main(cin);
	}
	return 0;
}


Measured memory_bytes: 256
package main

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


func InputString()(Input string){
                var scanner = bufio.NewScanner(os.Stdin)

                scanner.Scan()
                Input = scanner.Text()
                Input = strings.TrimSpace(Input)
                return
}



func main(){
                lineInputs := InputString()
                splited := strings.Split(lineInputs," ")
                index_one, err := strconv.Atoi(splited[0])
                if err != nil{
                                fmt.Println("error")
                }
                index_two,err := strconv.Atoi(splited[1])
                if err != nil{
                                fmt.Println("error")
                }

                if ((index_one*index_two)%2 == 0){
                                fmt.Println("Even")
                }else{
                                fmt.Println("Odd")
                }

}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int A, B, C, X, Y; 
  cin >> A >> B >> C >> X >> Y;

  int ans = INF;
  chmin(ans, A*X+B*Y);
  chmin(ans, max(X, Y)*2*C);

  int MIN = min(X, Y);
  X -= MIN; Y -= MIN;
  chmin(ans, MIN*C*2+A*X+B*Y);

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
words = gets.chomp.split(/ /).collect{|a| a.to_i}
ret = catch(:result) { 
  throw(:result, "NO") unless words.size == 3
  throw(:result, "NO") unless words.select{|a| a == 5}.size == 2
  throw(:result, "NO") unless words.select{|a| a == 7}.size == 1

  "YES"
}
puts ret

Measured memory_bytes: 14164
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn =new Scanner(System.in);
		int n=scn.nextInt();
		if(n>=30){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
			
	
		

	}

}

Measured memory_bytes: 35596
#include<bits/stdc++.h>
using namespace std;
int main(){
    unsigned long n;
    cin>>n;
    unsigned long temp=8*n+1;
    unsigned long temp1=sqrt(temp);
    if((temp1*temp1)==temp){
        if((temp1-1)%2==0){
            cout<<(temp1-1)/2;
            //cout<<"kk";
        }
        
    }
    else{
        //cout<<sqrt(temp);
        long double a=(sqrt(temp)-1)/2;
        cout<<(unsigned long)(a+1);
        //cout<<"á";
    }
}

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

#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()

#define rep(i,n) for(int i=0;i<n;++i)
#define Rep(i,a,n) for(int i=a;i<=n;++i)
#define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mset multiset
#define pqueue priority_queue
#define umap unordered_map
 
using namespace std;

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

const double PI=acos(-1),eps=1e-9;
const int dx[]={-1,1,0,0},dy[]={0,0,-1,1};
const int N=3e5+5,mod=2019,inf=1e9;

void solve(){
	ll l,r;
	cin>>l>>r;
	if(r-l+1>=5000){
		cout<<0;
		return;
	}
	ll ans=2019;
	for(ll i=l;i<=r;i++){
		for(ll j=i+1;j<=r;j++){
			ll x=i*j;
			ans=min(ans,x%mod);
		}
	}
	cout<<ans;
}

int main(){
	Speed();
	int T=1;
	//cin>>T;
	while(T--)solve();
}



Measured memory_bytes: 3556
#include <stdio.h>
#include <stdlib.h>

int check_each(int *p, int h, int w, int *xy, int k);
void kurai(int *xy, int h, int w);
void add(int *xy, int h, int w);

int main(void){
    int h, w, k;
    int i, j;
    int *cell;
    int *xy;
    int result = 0;


    scanf("%d %d %d", &h, &w, &k);
    cell = (int*)malloc(sizeof(int) * h * w);
    xy = (int*)malloc(sizeof(int) * (h + w));


    for(i = 0; i < h; i++){
        char str[w + 1];
        scanf("%s", str);

        for (j = 0; j < w; j++){
            if(str[j] == '.')
                cell[i * w + j] = 0;
            else{
                cell[i * w + j] = 1;
            }

        }
    }

    for(i = 0; i < h + w; i++){
        xy[i] = 0;
    }



    while(1){
        int conti = 0, count;
//        for(i = 0; i < h + w; i++){
//            printf("%d ", xy[i]);
//        }
//        printf("\n");
        count = check_each(cell, h, w, xy, k);

        if(count == k){
            result++;
            add(xy, h, w);

        }
        else if(count < k){
            kurai(xy, h, w);
        }
        else{
            add(xy, h, w);
        }

        for(i = 0; i < h + w; i++){
            if(xy[i] == 1){
                conti = 1;
                break;
            }
        }
        if(conti == 0)
            break;
    }

    printf("%d\n", result);

    free(cell);
    free(xy);


    return 0;
}


int check_each(int *p, int h, int w, int *xy, int k){
    int count = 0;
    int i, j;
    for(i = 0; i < h; i++){
        for (j = 0; j < w; j++){
            if(p[i * w + j] == 1 && xy[i] == 0 && xy[h + j] == 0)
                count++;
        }
    }
    return count;
}

void kurai(int *xy, int h, int w){
    int i;
    for(i = 0; i < h + w; i++){
        if(xy[i] == 0)
            xy[i] = 1;
        else
            break;
    }
    add(xy, h, w);
    return;
}
void add(int *xy, int h, int w){
    int i;
    for(i = 0; i < h + w; i++){
        if(xy[i] == 0){
            xy[i] = 1;
            return;
        }
        else
            xy[i] = 0;
    }
    return;
}

Measured memory_bytes: 1732
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){ 
    int n,s,c=0 ; 
    cin>>n>>s; 
    for (int i=s;i<=n;i++) 
    	if (i%s==0) c++; 
    int ans=c*c*c;
    if (s%2==0){
    	c=0;
    	for (int i=s/2;i<=n;i+=s) c++;
    	ans += (c*c*c);
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3596
/**
 * Motto:   fight till end
 * Author: fyter_112
 **/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ump unordered_map<int,int>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define rep(i,a,n) for(int i=a;i<(n);i++)
#define all(x) x.begin(),x.end()
#define reps(i,j,n)   for(int i=(j);i>=(n);i--)
#define ld long double
#define count(i,n) for(i=n;i>0;i=i/10)
#define mod 1000000007
int32_t main()
{
  int a,b,c;
  cin>>a>>b>>c;
  cout << c <<" "<<a <<" " <<b <<'\n';
}


Measured memory_bytes: 256
def oddFun(num):
	return num//2
 
def evenFun(num):
	return (3 * num) + 1
 
s = int(input())
set = set()
index = 1
while s not in set:
	set.add(s)
	if s % 2 == 0:
		s = oddFun(s)
	else:
		s = evenFun(s)
	index+=1

print(index)

Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int main(){
	float input;
	while(scanf("%f", &input) != EOF){
		int ans = 1;
		while(1){
			float time = sqrt((5*ans - 5) / 4.9);
			float speed = time * 9.8;
			if(input < speed) break;
			ans++;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int d;
    cin >> d;
    vi  c(26);
    REP(i, 26) cin >> c[i];
    vvl s(d, vl(26));
    REP(i, d) REP(j, 26) cin >> s[i][j];

    vl t(d);
    REP(i, d) cin >> t[i];

    int m;
    cin >> m;
    vector<pair<int, int>> q(m);
    REP(i, m) cin >> q[i].first >> q[i].second;

    REP(k, m) {
        vi last(26);
        ll ans = 0;
        REP(i, d) {
            int x = t[i] - 1;
            if (q[k].first - 1 == i) {
                x = q[k].second - 1;
                t[i] = q[k].second;
            }
            ans += s[i][x];
            last[x] = i + 1;
            REP(j, 26) {
                ans -= c[j] * ((i + 1) - last[j]);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3800
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;


int main()
{

    int a;
    string input;
    cin>>a>>input;

    int b=0;
    char i='I';

    int maxi[a+1];

    for (int c=0;c<a;c++)
    {
        if(input[c]==i)
        {
            b=b+1;
        }

        else {
            b=b-1;
        }

        maxi[c]=b;

    }
    maxi[a]=0;
    sort (maxi,maxi+(a+1));

    cout << maxi[a];

}


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

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

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int x, y, a, b, c;
VI p(10010), q(10010), r(10010);

signed main()
{
    cin >> x >> y >> a >> b >> c;
    p.resize(a);
    q.resize(b);
    r.resize(c);
    REP(i, p.size()){
        cin >> p[i];
    }
    REP(i, q.size()){
        cin >> q[i];
    }
    REP(i, r.size()){
        cin >> r[i];
    }

    sort(ALL(p), [](int s, int t){ return s > t; });
    sort(ALL(q), [](int s, int t){ return s > t; });
    sort(ALL(r), [](int s, int t){ return s > t; });

    p.resize(x);
    q.resize(y);

    r.insert(r.end(),ALL(p));
    r.insert(r.end(),ALL(q));

    sort(ALL(r),  [](int s, int t){ return s > t; });

    int res = 0;
    REP(i, x+y){
        res += r[i];
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 6276
#include <iostream>
using namespace std;
int main() {
	int n, a[100], b[100], c[100];
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i) cin >> b[i];
	for (int i = 0; i < n - 1; ++i) cin >> c[i];
	int s = 0;
	for (int i = 0; i < n; ++i) {
			s += b[a[i] - 1];
		if (i > 0 && a[i - 1] + 1 == a[i]) s += c[a[i - 1] - 1];
	}
	cout << s;
}

Measured memory_bytes: 256
// Last Change: 03/28/2019 18:19:45.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  int D, N;
  cin >> D >> N;

  ll ans = N;
  if (N == 100) {
    ++ans;
  }
  for (int i = 0; i < D; ++i) {
    ans *= 100;
  }

  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
#include<cstdio>
const int N=1002;
int n,x,i,s[N],sum,p;
int min(int x,int y){
	return x<y?x:y;
}
int main(){
	scanf("%d",&n);
	while(n--){
		scanf("%d",&x);
		if(x>=1&&x<=399)s[1]++;
		if(x>=400&&x<=799)s[2]++;
		if(x>=800&&x<=1199)s[3]++;
		if(x>=1200&&x<=1599)s[4]++;
		if(x>=1600&&x<=1999)s[5]++;
		if(x>=2000&&x<=2399)s[6]++;
		if(x>=2400&&x<=2799)s[7]++;
		if(x>=2800&&x<=3199)s[8]++;
		if(x>=3200)sum++;
	}
	for(i=1;i<=8;i++)
		p+=s[i]>0;
	if(sum==0)
		printf("%d %d",p,p);
	else{
		if(p==0)
			printf("%d %d",1,sum);
		else
			printf("%d %d",p,p+sum);
	}
	//while(1);
}


Measured memory_bytes: 128
/******************************************
 * Try to be a Rainbow in Someone's cloud.*
 *                                        *
 ******************************************/

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define DHOKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll dp[3][100005];
ll a[3][100005];
int main(){
   DHOKHA;
   ll n;
   cin>>n;
   ll i;
   for(i=0;i<n;i++){
   	cin>>a[0][i]>>a[1][i]>>a[2][i];
   }
   dp[0][0]=a[0][0];
   dp[1][0]=a[1][0];
   dp[2][0]=a[2][0];
   for(i=1;i<n;i++){
   	dp[0][i]=a[0][i]+max(dp[1][i-1],dp[2][i-1]);
   	dp[1][i]=a[1][i]+max(dp[0][i-1],dp[2][i-1]);
   	dp[2][i]=a[2][i]+max(dp[1][i-1],dp[0][i-1]);
   	
   }
   cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
   
   
}



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



// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    string S ;
    cin >> S ;
    int Q;
    cin >> Q;
    bool flag=false;//反転しているときtrue
    string foward;
    string back;
    for (int i=0;i<Q;i++){
        int T,F;
        char C;
        scanf("%d",&T);
        if (T==1){
            if (flag){
                flag=false;
            }else{
                flag=true;
            }
        }else if (T==2){
            scanf("%d %c",&F,&C);
            if (F==1){
                if (!flag){//反転していないとき
                    foward.push_back(C);
                }else{
                    back.push_back(C);
                }
            }else{
                if (!flag){//反転していないとき
                    back.push_back(C);
                }else{
                    foward.push_back(C);
                }
    
            }
        }
    }
    if (!flag){
        std::reverse(foward.begin(),foward.end());
        cout << foward << S << back << endl;
    }else{
        std::reverse(back.begin(),back.end());
        reverse(S.begin(),S.end()) ;
        cout << back << S << foward << endl;
    }

    return 0;
}


Measured memory_bytes: 1088
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();

    let hw: Vec<_> = s.trim().split(' ').map(|x| x.parse().unwrap()).collect();

    let mut xs = vec![vec![false; hw[1]]; hw[0]];

    let mut res = true;

    'outer:
    for i in 0..hw[0] {
        let mut s = String::new();
        io::stdin().read_line(&mut s).ok();
        if !res {
            continue;
        }

        let cs: Vec<_> = s.trim().chars().collect();

        for j in 0..hw[1] {
            if cs[j] == '.' {
                continue;
            }

            if i == j && i == 0 {
                xs[i][j] = true;
                continue;
            }

            let f1 = if i == 0 {
                false
            }
            else {
                xs[i - 1][j]
            };

            let f2 = if j == 0 {
                false
            }
            else {
                xs[i][j - 1]
            };

            res = f1 != f2;
            xs[i][j] = res;

            if !res {
                break 'outer;
            }
        }
    }

    if res {
        'outer2:
        for i in 0..hw[0] {
            for j in 0..hw[1] {
                if i == hw[0] - 1 && j == hw[1] -1 {
                    break 'outer2;
                }

                if !xs[i][j] {
                    continue;
                }

                let f1 = if i == hw[0] - 1 {
                    false
                }
                else {
                    xs[i + 1][j]
                };

                let f2 = if j == hw[1] - 1 {
                    false
                }
                else {
                    xs[i][j + 1]
                };

                res = f1 != f2;
                if !res {
                    break 'outer2;
                }
            }
        }
    }

    println!("{}", if res {
        "Possible"
    }
    else {
        "Impossible"
    });
}


Measured memory_bytes: 508
using System;
using System.Linq;

namespace ABC027
{
    class A
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int N = int.Parse(input[0]);
            int x = int.Parse(input[1]);

            int[] a = Console.ReadLine().Split().Select(int.Parse).OrderBy(y => y).ToArray();

            int count = 0;
            for (int i = 0; i < N; i++)
            {
                x -= a[i];
                if (0 <= x) count++;
                if (x < 0) break;
            }
            if (0 < x) count--;
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

#define rep(i,n) for(int i;i<(int)n;i++)
#define rep2(i,begin_i,end_i) for(int i=(int)begin;i<(int)end;i++)

int main(){
    int n;
    cin>>n;
    int64_t l=1,temp=2,temp_temp=0;
        rep(i,n+1){
            if(i==0){
                l=2;
            }
            else if(i==1){
                l=1;
            }
            else{
            temp_temp=temp;
            temp=l;
            l=temp+temp_temp;
            }
        }
        cout<<l<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
struct dice{
  int x,y,z;
  int top,front,bottom,back,right,left;
  void roll(int d){
    //cout << d << endl;
    int buf;
    if(d==0){
      buf=top;top=back;back=bottom;bottom=front;front=buf;x--;
    }else if(d==1){
      buf=top;top=left;left=bottom;bottom=right;right=buf;z++;
    }else if(d==2){
      buf=top;top=front;front=bottom;bottom=back;back=buf;x++;
    }else if(d==3){
      buf=top;top=right;right=bottom;bottom=left;left=buf;z--;
    }
    y--;
  }
  
};
int ch(int a,int b){
  int x=0;
  if(a==1&&b==3) x=5;if(a==1&&b==5) x=4;if(a==1&&b==4) x=2;if(a==1&&b==2) x=3;
  if(a==2&&b==3) x=1;if(a==2&&b==1) x=4;if(a==2&&b==4) x=6;if(a==2&&b==6) x=3;
  if(a==3&&b==6) x=5;if(a==3&&b==5) x=1;if(a==3&&b==1) x=2;if(a==3&&b==2) x=6;
  if(a==4&&b==1) x=5;if(a==4&&b==5) x=6;if(a==4&&b==6) x=2;if(a==4&&b==2) x=1;
  if(a==5&&b==3) x=6;if(a==5&&b==6) x=4;if(a==5&&b==4) x=1;if(a==5&&b==1) x=3;
  if(a==6&&b==4) x=5;if(a==6&&b==5) x=3;if(a==6&&b==3) x=2;if(a==6&&b==2) x=4;
  return x;
}

int main(){
  int n;
  cin >> n;
  while(n!=0){
    
    int i,j,k;
    int ex[100][100][100]={{{}}};
    dice d;
    vector<dice> v;
    
    for(i=0;i<n;i++){
      cin >> d.top >> d.front;
      d.bottom=7-d.top;
      d.back=7-d.front;
      d.right=ch(d.top,d.front);
      d.left=7-d.right;
      d.x=50;d.y=50;d.z=50;
      int f=0;
      while(f==0){
	//cout << d.y << endl;
	if(d.y==0) f=1;
	else if(ex[d.x][d.y-1][d.z]==0) d.y--;
	else {
	  if(d.front==6&&ex[d.x-1][d.y-1][d.z]==0) d.roll(0);
	  else if(d.right==6&&ex[d.x][d.y-1][d.z+1]==0) d.roll(1);
	  else if(d.back==6&&ex[d.x+1][d.y-1][d.z]==0) d.roll(2);
	  else if(d.left==6&&ex[d.x][d.y-1][d.z-1]==0) d.roll(3);
	  else if(d.front==5&&ex[d.x-1][d.y-1][d.z]==0) d.roll(0);
	  else if(d.right==5&&ex[d.x][d.y-1][d.z+1]==0) d.roll(1);
	  else if(d.back==5&&ex[d.x+1][d.y-1][d.z]==0) d.roll(2);
	  else if(d.left==5&&ex[d.x][d.y-1][d.z-1]==0) d.roll(3);
	  else if(d.front==4&&ex[d.x-1][d.y-1][d.z]==0) d.roll(0);
	  else if(d.right==4&&ex[d.x][d.y-1][d.z+1]==0) d.roll(1);
	  else if(d.back==4&&ex[d.x+1][d.y-1][d.z]==0) d.roll(2);
	  else if(d.left==4&&ex[d.x][d.y-1][d.z-1]==0) d.roll(3);
	  else f=1;
	}
      }
      ex[d.x][d.y][d.z]=1;
      v.push_back(d);
    }
    
    int o[7]={};
    for(i=0;i<v.size();i++) {
      if(ex[v[i].x][v[i].y+1][v[i].z]==0) o[v[i].top]++;
    }
    cout << o[1];
    for(i=2;i<=6;i++) cout << " " << o[i];
    cout << endl;
    cin >> n;
  }
  return 0;
}

Measured memory_bytes: 5132
#include <bits/stdc++.h>
#define F first
#define S second
#define ld long douroote
#define pb push_back
#define sz size
#define ll long long
#define ull unsigned long long
#define INF 0x7f7f7f7f
#define sc(a) scanf("%d",&a)
#define scll(a) scanf("%lld",&a)
#define scd(a) scanf("%lf",&a)
#define scc(a) scanf(" %c",&a)
#define scs(a) scanf(" %s",a)
#define me(a,b) memset(a,b,sizeof a)
#define all(a) a.begin(),a.end()
#define allr(a,n) a,a+n
#define loop(a,s,e) for(ll a=s;a<=e;a++)
#define read_arr(a,s,n) for(int i=s;i<n+s;i++){sc(a[i]);}
#define read_arr_ll(a,s,n) for(int i=s;i<n+s;i++){scll(a[i]);}
#define err(a,s) cerr<<a<<s;
#define err_arr(a,s,n) for(int i=s;i<n+s;i++){cerr<<a[i]<<" ";}cerr<<endl;
#define prtll(x) printf("%lld",x);
#define prt(x) printf("%d",x);
using namespace std;
const int N=1e4+10;
char g[N][N];
char s[N];
int n,m,mem[N][N],mod=1e9+7;
ll dp(int i,int j){
if(i>n || j>m){return 0;}
if(g[i][j]=='#'){return 0;}
if(i==n && j==m){return 1;}
int &ret=mem[i][j];
if(ret!=-1){return ret;}
ret=0;
ret+=dp(i+1,j)%mod;
ret%=mod;
ret+=dp(i,j+1)%mod;
ret%=mod;
return ret;
}
int main(){
sc(n);sc(m);
loop(i,1,n){
scs(s);
loop(j,1,m){g[i][j]=s[j-1];}
}
me(mem,-1);
int ans=dp(1,1);
printf("%d\n",ans);
return 0;
}
/**
**/


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

typedef long long ll;
ll tr[1600001];
ll lz[1600001];
void push(int in){
  tr[in] += lz[in];
  lz[2 * in] += lz[in];
  lz[2 * in + 1] += lz[in];
  lz[in] = 0;
}
ll get(int in, int l, int r, int s, int e){
  push(in);
  if(l > e || r < s)
    return -1e18;
  if(l >= s && r <= e)
    return tr[in];
  int m = (l + r) / 2;
  return max(get(2 * in, l, m, s, e), get(2 * in + 1, m + 1, r, s, e));
}
void add(int in, int l, int r, int s, int e, ll v){
  push(in);
  if(l > e || r < s)
    return;
  if(l >= s && r <= e){
    lz[in] += v;
    push(in);
    return;
  }
  int m = (l + r) / 2;
  add(2 * in, l, m, s, e, v);
  add(2 * in + 1, m + 1, r, s, e, v);
  tr[in] = max(tr[2 * in], tr[2 * in + 1]);
}
struct E{
  int in, v;
  int l, r;
  bool add;
};
int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n, m;
  cin >> n >> m;
//  add(1, 0, n - 1, 0, 0, 10);
//  cout << get(1, 0, n - 1, 0, n - 1);
//  return 0;
  vector<E> es(2 * m);
  for(int i = 0;i < m;i++){
    int l, r, v;
    scanf("%d %d %d", &l, &r, &v);
    l--, r--;
    es[2 * i].in = l;
    es[2 * i].l = l;
    es[2 * i].r = r;
    es[2 * i].v = v;
    es[2 * i].add = true;
    es[2 * i + 1].in = r + 1;
    es[2 * i + 1].l = l;
    es[2 * i + 1].r = r;
    es[2 * i + 1].v = v;
    es[2 * i + 1].add = false;
  }
  sort(es.begin(), es.end(), [](const E& a, const E& b){
    return a.in < b.in;
  });
//  for(auto el : es){
//    cout << el.in << ' ' << el.l << ' ' << el.r << ' ' << el.v << ' ' << el.add << endl;
//  }
  int cure = 0;
  ll dp[n];
  ll cursum = 0;
  ll mx = 0;
  for(int i = 0;i < n;i++){
    while(cure < 2 * m && es[cure].in == i){

      if(es[cure].add){
        cursum += es[cure].v;
        add(1, 0, n - 1, es[cure].l, es[cure].r, -es[cure].v);
      }else{
        cursum -= es[cure].v;
        add(1, 0, n - 1, es[cure].l, es[cure].r, es[cure].v);
      }
      cure++;
    }
//    if(i)
//      cout << get(1, 0, n - 1, 0, i - 1) << ' ';
//    for(int j = 0;j < n;j++){
//      cout << get(1, 0, n - 1, j, j) << ' ';
//    }
//    cout << endl;
    dp[i] = cursum;
    if(i){
      dp[i] = max(dp[i], cursum + get(1, 0, n - 1, 0, i - 1));
    }
    add(1, 0, n - 1, i, i, dp[i]);
//    cout << cursum << endl;
//    cout << dp[i] << endl;
//    for(int j = 0;j < n;j++){
//      cout << get(1, 0, n - 1, j, j) << ' ';
//    }
//    cout << endl;
    mx = max(mx, dp[i]);
  }
  cout << mx;
  return 0;
}


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

ll dp[100100][4] ;
int main()
{
	string s;
	cin >> s;
	ll n = s.size() ;
	rep(i,100100){
		rep(j,4){
			dp[i][j] = 0;
		}
	}
	dp[0][0] = 1 ;
	rep(i,n){
		ll num = s[i] - 'A'+1;
		//状態numを更新する。
		rep(j,4) dp[i+1][j] = dp[i][j];

		if(s[i]=='?'){
			rep(j,4){
				dp[i+1][j] *= 3;
				dp[i+1][j] %= mod;
			}
			for(ll j = 1 ; j <= 3 ; j++){
				 dp[i+1][j] += (dp[i][j-1]);
				 dp[i+1][j] %= mod;
			}
		} else {
			dp[i+1][num] += dp[i][num-1] ;
			dp[i+1][num]%= mod;
		}
	} 
	cout << dp[n][3] << endl;
}


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

# define LocalJudge( File ) freopen ( File ".in", "r", stdin )  ;

using namespace std ;

inline void smin ( long long& d, long long x )  {  ( d > x ) ? d = x : 0 ;  }

const long long inf = ( ~0ull >> 1 ) ;
const int N = 500010 ;

long long a [N] ;
int q [N] ;
bool inq [N] ;
vector < pair < int, int > > g [N] ;

int main ( )  {
	int h, w, cnt ;
	scanf ( "%d %d", & h, & w ) ;
	scanf ( "%d", & cnt ) ;
	for ( int i = 0 ; i < h + w ; ++ i )	g [i].clear ( ) ;
	memset ( inq, 0, sizeof ( bool ) * ( h + w ) ) ;
	for ( int i = 0 ; i < cnt ; ++ i )  {
		int x, y, z ;
		scanf ( "%d %d %d", & x, & y, & z ) ;
		-- x, -- y ;
		g [x].push_back ( make_pair ( h + y, z ) ) ;
		g [h + y].push_back ( make_pair ( x, z ) ) ;
	}
	for ( int i = 0, l = h + w ; i < l ; ++ i )  {
		if ( inq [i] )  {
			continue ;
		}
		int b = 0, e = 1 ;
		q [0] = i ;
		inq [i] = true ;
		a [i] = 0 ;
		while ( b < e )  {
			for ( int j = 0, l = ( int ) g [q [b]].size ( ) ; j < l ; ++ j )  {
				int u = g [q [b]] [j].first ;
				int v = g [q [b]] [j].second ;
				if ( inq [u] )  {
					if ( a [q [b]] + a [u] != v )  {
						puts ( "No" ) ;
						goto h ;
					}
					continue ;
				}
				q [e] = u ;
				a [u] = v - a [q [b]] ;
				inq [u] = true ;
				++ e ;
			}
			++ b ;
		}
		long long m1 = inf, m2 = inf ;
		for ( int j = 0 ; j < e ; ++ j )  {
			if ( q [j] < h ) {
				smin ( m1, a [q [j]] ) ;
			}  else  {
				smin ( m2, a [q [j]] ) ;
			}
		}
		if ( m1 + m2 < 0 )  {
			puts ( "No" ) ;
			goto h ;
		}
	}
	puts ( "Yes" ) ;
	h : ;
}

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

//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3", "Ofast", "unroll-loops", "fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#define int long long
#define endl '\n'

using namespace std;

signed main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int i, j, n, k;
    cin >> k >> n;
    vector < int > a(n);
    for (i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = a[n - 1] - a[0];
    int ma1 = 0, ma2 = 0;
    for (i = 0; i < n - 1; i++){
        ans = min(ans, a[i] + k - a[i + 1]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>
#include <math.h>
int main(void)
{
    double a,b,t;
    scanf("%lf%lf%lf",&a,&b,&t);
    printf("%lf\n%lf\n%lf\n",(sin(t*3.14159265359/180)*a*b)/2,a+b+sqrt(a*a+b*b-2*a*b*cos(t*3.14159265359/180)),sin(t*3.14159265359/180)*b);
}


Measured memory_bytes: 2104
#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;
typedef pair<ll, ll> PLL;

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

// --------------------------------------
ll x;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> x;

  ll ans = 0;
  ans += (x / 500) * 1000;
  x %= 500;
  ans += (x / 5) * 5;

  cout << ans << endl;
}


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

#define for(i, a, b) for(ll (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)

const ll inf = 1e15;
const ll mod = 1e9+7;

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

int main() {
    ll N; cin >> N;
    vector<ll> T(N), A(N); rep(i, N) cin >> T[i] >> A[i];
    
    ll t = 1, a = 1;
    rep(i, N) {
        ll n = max((a + A[i] - 1) / A[i], (t + T[i] - 1) / T[i]);
        a = A[i] * n;
        t = T[i] * n;
    }
    cout << a + t << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=600001,INF=1<<30;

int par[MAX],size[MAX];

void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        size[i]=1;
    }
}

int root(int a){
    if(par[a]==a) return a;
    else return par[a]=root(par[a]);
}

void unite(int a,int b){
    if(root(a)!=root(b)){
        size[root(a)]+=size[root(b)];
        par[root(b)]=root(a);
    }
}

bool check(int a,int b){
    return root(a)==root(b);
}

int main(){
    
    string preS,T,S;cin>>preS>>T;
    int L=T.size();
    
    while(int(S.size())<2*int(T.size())+int(preS.size())) S+=preS;
    
    T+=S;
    
    vector<int> A(T.size());
    
    int c=0;
    for(int i=1;i<T.size();i++){
        if(i+A[i-c]<c+A[c]){
            A[i]=A[i-c];
        }else{
            int j=max(0,c+A[c]-i);
            while(i+j<T.size()&&T[j]==T[i+j]) j++;
            A[i]=j;
            c=i;
        }
    }
    A[0]=T.size();
    
    for(int i=0;i<preS.size();i++){
        A[i]=A[i+L];
        if(A[i]>=L) A[i]=1;
        else A[i]=0;
        //cout<<A[i]<<endl;
    }
    
    init(int(preS.size()));
    
    for(int i=0;i<preS.size();i++){
        if(A[i]==0) continue;
        int j=(i+L)%int(preS.size());
        if(check(i,j)){
            cout<<-1<<endl;
            return 0;
        }
        unite(i,j);
    }
    
    int ans=-1;
    
    for(int i=0;i<preS.size();i++){
        ans=max(ans,size[root(i)]-1);
    }
    
    cout<<ans<<endl;
    
    
}


Measured memory_bytes: 24156
/*"Everything in the universe is balanced. Every disappointment
   you face in life will be balanced by something good for you!
                Keep going, never give up."            */

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

#define ll long long
const ll N=1e6+9;
const ll mod=1e9+7;

ll a[N];

void solve()
{    
    ll n, m ;
    cin >>n >>m ;
    vector<int> a(n), dp(m+1,0) ;
    for(int i = 0 ;i<n; i++)cin>>a[i];
    for(int i=0; i<=m; i++){
    	int flag = 0 ; 
    	for( int j = 0 ; j< n; j++){
    		if(i-a[j]>=0 && dp[i-a[j]]==0)flag = 1 ;
    	}
    	dp[i] = flag ;
    	//cout<<i<<dp[i]<<"<<";
    }	
   	if(dp[m])cout<<"First";
   	else cout<<"Second";

}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t=1;
    //pre();
    //cin>>t;
    while(t--)
    {
      solve();
    }  
}


// Xorawar

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

int main() {
	long long a, b, c, d, max1 = -1, max2 = -1;
	bool yes = false;
	cin >> a >> b >> c >> d;
	if(b >= 0 && d >= 0) {
		max1 = b * d;
		yes = true;
	}
	if(a <= 0 && c <= 0) {
		max2 = a * c;
		yes = true;
	}
	if(!yes) {
		if(a > 0) cout << a * d;
		else cout << b * c;
		return 0;
	}
	if(max1 == -1) cout << max2;
	else if(max2 == -1) cout << max1;
	else cout << max(max1, max2);
	return 0;
}

Measured memory_bytes: 3628
import collections

n = int(input())
g = [[] for i in range(n)]
for i in range(n):
    S =input()
    for j in range(i+1,n):
        if S[j]=="1":
            g[i].append(j)
            g[j].append(i)
def bfs(s):
    vis = [False]*n
    cnts=[0]*n
    que = collections.deque()
    cnt=1
    que.append((s,cnt))
    vis[s]=True
    cnts[s]=1
    while que:
        s,cnt = que.popleft()
        for node in g[s]:
            if not vis[node]:
                vis[node]=True
                cnts[node]=cnt+1
                que.append((node,cnt+1))
            else:
                if (cnts[node]+cnt)%2==0:
                    print(-1)
                    exit()
    return cnt
ans = 0
for node in range(n):
    ans = max(bfs(node),ans)
print(ans)


Measured memory_bytes: 68992
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<stack>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;

struct Point{
	double x,y;
	Point(){}
	Point(double _x,double _y){
		x=_x; y=_y;
	}
};

int main(){
	Point ans[1001]={};
	ans[1] = Point(1,0);
	for(int i=2;i<=1000;i++){
		double r = atan2(-ans[i-1].y,-ans[i-1].x);
		r += -1.0/2.0*M_PI;
		ans[i] = Point(ans[i-1].x+cos(r),ans[i-1].y+sin(r));
	}
	int N;
	while(cin>>N,~N){
		printf("%lf\n%lf\n",ans[N].x,ans[N].y);
	}
}

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

using namespace std;

int main(){
	
	int H, W;
	cin >> H >> W;
	
	string str[100];
	
	for(int i = 0; i < H; i++){
		cin >> str[i];
	}
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(str[i][j] == '#'){
				continue;
			}
			str[i][j] = '0';
			for(int di = -1; di <= 1; di++){
				if(i + di < 0 || i + di >= H){
					continue;
				}
				for(int dj = -1; dj <= 1; dj++){
					if(j + dj < 0 || j + dj >= W){
						continue;
					}
					if(str[i + di][j + dj] == '#'){
						str[i][j]++;
					}
				}
			}
		}
	}
	
	for(int i = 0; i < H; i++){
		cout << str[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
p.append(0)
cnt = 0
skip = False
for i in range(n):
    if skip == True:
        skip = False
        continue
    else:
        if p[i] == i+1:
            if p[i+1] == i+2:
                cnt += 1
                skip = True
            else:
                cnt += 1
print(cnt)
        

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

int main() {
  int n;
  cin >> n;
  vector<int> t(n + 1), x(n + 1), y(n + 1);
  t.at(0) = 0;
  x.at(0) = 0;
  y.at(0) = 0;
  for (int i = 1; i < n + 1; i++)
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  vector<int> dist(n);
  for (int i = 0; i < n; i++)
    dist.at(i) = max(x.at(i + 1) - x.at(i), x.at(i) - x.at(i + 1))
      + max(y.at(i + 1) - y.at(i), y.at(i) - y.at(i + 1));
  for (int i = 0; i < n; i++) {
    if (t.at(i + 1) - t.at(i) < dist.at(i)
        ||
        (t.at(i + 1) - t.at(i)) % 2 != dist.at(i) % 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amin(T& a,T b){ a=min(a,b);}


int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll x, ans=0, sm=0;
	cin >>x;
	for(ll i=1;  ; i++){
		sm += i;
		if(sm >=x){
			cout << i <<"\n";
			return 0;
		}
	}
	return 0;
}

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

#define MAXN 100001

using namespace std;

vector<int> ady[MAXN];
bool visited[MAXN];
int dist[MAXN];
stack<int> s;

void Dfs(int v){
    visited[v] = true;
    for(auto x:ady[v])
        if(!visited[x])
            Dfs(x);
    s.push(v);
}

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

    int n, m, a, b;
    cin >> n >> m;

    for(int i = 0; i < m; ++i){
        cin >> a >> b;
        ady[a].push_back(b);
    }

    for(int i = 1; i <= n; ++i){
        if(!visited[i])
            Dfs(i);
    }

    while(!s.empty()){
        for(auto x:ady[s.top()])
            dist[x] = max(dist[x], dist[s.top()] + 1);
        s.pop();
    }

    int ans = 0;
    for(int i = 1; i <= n; ++i)
        ans = max(ans, dist[i]);
    cout << ans << "\n";

    return 0;
}//RUL0

Measured memory_bytes: 8704
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

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



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

using namespace std;

typedef long long ll;

using V = vector<int>;
using Q = queue<int>;
using Graph = vector<vector<int>>;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl
#define err(x) cerr<<(x)<<endl
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 200010
#define lim9 1000000010

#define deg(_rad) (((_rad)/2/M_PI)*360)
#define rad(_deg) (((_deg)/360)*2*M_PI)
#define mid(min, max) ((min + max) / 2)

int main() {
    char c;
	cin >> c;
	if ('a' <= c && c <= 'z') {
		out("a");
		return 0;
	}
	out("A");
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define db(x) cout << #x << " = " << (x) << "\n";
using ll = long long;
using ld = long double;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector<vector<int>> v(n + 1, vector<int>(3));
    vector<vector<int>> max_points(n + 1, vector<int>(3));
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> v[i][j];
        }
    }

    int next1, next2;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            next1 = (j + 1) % 3;
            next2 = (j + 2) % 3;
            max_points[i + 1][next1] = max(
                max_points[i + 1][next1],
                max_points[i][j] + v[i + 1][next1]);
            max_points[i + 1][next2] = max(
                max_points[i + 1][next2],
                max_points[i][j] + v[i + 1][next2]);
        }
    }
    int ans = 0;
    for (int i = 0; i < 3; i++)
    {
        ans = max(ans, max_points[n][i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 11136
from math import gcd

k = int(input())

ans = 0

for a in range(1, k + 1, 1):
    for b in range(1, k + 1, 1):
        g = gcd(a, b)
        for c in range(1, k + 1, 1):
            ans += gcd(g, c)

print(ans)

Measured memory_bytes: 9188
N = int(input())
height_list = [int(i) for i in input().split()]

# 全探索
ans = 0 # 1番目は見えるので
tmp_max = -1
for i in range(N) :
    if(height_list[i] >= tmp_max) :
        tmp_max = height_list[i]
        ans += 1
        

print(ans)



Measured memory_bytes: 2940
// Who_Says_a_Pun? 
// https://atcoder.jp/contests/abc141/tasks/abc141_e
// date: 2020-08-11T20:47:18.409724

// #配列の初期化 #0埋め #memsetではなく{0}

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

#define REP(i, n) for(ll i=0;i<ll(n);i++)
#define REPD(i, n) for(ll i=n-1;i>=0;i--)
#define FOR(i, a, b) for(ll i=a;i<=ll(b);i++)
#define FORD(i, a, b) for(ll i=a;i>=ll(b);i--)

#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

template<typename T, typename ...Args>
void IN(T& first, Args&... args) {
    ((cin >> first), ..., (cin >> args)); //C++17
}

template<char Sep, typename T, typename ...Args>
void print_sep(const T& first, const Args&... args) {
    ((cout << first), ..., (cout << Sep << args)); //C++17
}

template<typename... Words>
void OUT(Words... words) {
    print_sep<' '>(words...);
    cout << endl;
    return;
}

#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 5000 //10^5:配列の最大のrange

int main(void){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    ll N;
    string s;
    IN(N);
    IN(s);

    // https://qiita.com/Ki4mTaria/items/b6ab0bcbe9c87d4dc071#%E9%85%8D%E5%88%97%E6%A7%8B%E9%80%A0%E4%BD%93%E3%81%AE%E4%B8%AD%E8%BA%AB
    static bool arr[MAXR][MAXR]= {false};
    REP(i,N) FOR(j,i,N) {
        arr[i][j] = s[i] == s[j];
    }

    ll max_len=0;
    FOR(i, 1, N-1) {
        ll buf_len=0;
        FOR(j, 0, N - i - 1) {
            if (arr[j][i+j]) {
                buf_len++;
            } else{
                buf_len=0;
            }
            max_len = max(max_len, buf_len);
            if (buf_len==i) {
                break;
            }
        }
    }
    OUT(max_len);
    return 0;

}


Measured memory_bytes: 27624