akhauriyash/Code-Regression huggingface dataset:
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
char g[11][11];
int n,m;
int main()
{
	getii(n,m);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			g[i][j]=getreal();
		}
	}
	int x=1,y=1;
	while(x<=n&&y<=m)
	{
		g[x][y]='o';
		if(x==n&&y==m)break;
		if(x+1<=n&&g[x+1][y]=='#')x++;
		else if(y+1<=m&&g[x][y+1]=='#')y++;
		else break;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(g[i][j]=='#')
			{
				puts("Impossible");
				return 0;
			}
		}
	}
	puts("Possible");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX = 2e5;


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

    map<string, int> freq;


    int most = 0;
    string s;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        auto it = freq.find(s);
        if (it == freq.end()) {
            it = freq.insert({s, 0}).first;

        }
        it->second++;
        most = max(most, it->second);
    }

    for (auto itr = freq.begin(); itr != freq.end(); ++itr) {
        if (itr->second == most) {
            cout << itr->first << "\n";
        }
    }

    return 0;
}


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

signed main(){
	char a;
	bool ans  = false;
	cin>>a;
	
	if(a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o')ans = true;
	
	cout<<(ans?"vowel":"consonant")<<endl;
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: u64,
        m: u64,
    }
    let s = std::cmp::min(n,m/2);
    let c = (m - (s * 2)) / 4;
    println!("{}", s + c);
}


Measured memory_bytes: 4352
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=2019;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    string s;
    cin >> s;
    int n = s.length();
    unordered_map<int, int> data;
    data[0] = 1;
    int curr = 0, ans = 0;
    for (int i = n-1; i >= 0; i--) {
        curr += (powmod(10, n-i-1)*(s[i] - '0'))%2019;
        curr %= 2019;
        ans += data[curr];
        data[curr]++;
    }
    cout << ans << "\n";
}



Measured memory_bytes: 3744
// This code writed by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
#define int long long
using namespace std;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
signed main(void)
{
	int a;
	cin>>a;
	reg int ans=a;
	reg int maxi=sqrt(a);
	for(int i=1;i<=maxi;++i)
		if(!(a%i))
		{
			reg int res=2ll*i-1ll;
			res+=a/i-i-1ll;
			ans=min(ans,res);
		}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int a = 0, b = 0, c = 0;
	int buf = 0;
	
	cin >> a >> b >> c;
	
	do{
		if(a > b){
			buf = a;
			a = b;
			b = buf;
		}
		if(b > c){
			buf = b;
			b = c;
			c = buf;
		}
	}while(!(a <= b && b <= c));
	
	cout << a << " " << b << " " << c << endl;
	
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>

using namespace std;

int main()
{
    int n;
    int a[10], b[10];
    int x, y;
    string s, t, perm;
    int cnt = 1;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s += (a[i] + '0');
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        t += (b[i] + '0');
        perm += ((i+1) + '0');
    }

    do {
        if (s == perm) {
            x = cnt;
        }
        if (t == perm) {
            y = cnt;
        }
        cnt++;
    } while (next_permutation(perm.begin(), perm.end()));

    cout << abs(y-x) << endl;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)
#include "bits/stdc++.h"
using namespace std;

//template
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,a,b) for(int i=(int)(b) - 1;i>=(int)(a);i--)
#define rrep(i,n) RREP(i,0,n)
#define each(i, ctn) for (auto &&i : (ctn))

using ll = long long;
using ull = unsigned long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
#define all(a) (a).begin(),(a).end()
template<typename A, typename T>
void assign2d(A&arr, ll H, ll W, T t) {
	arr.resize(H);
	for (ll i = 0; i < H; i++) {
		arr[i].assign(W, t);
	}
}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T in() { T x; cin >> x; return x; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
//pair
using P = pair<ll, ll>;
#define mp make_pair



int main() {
	ll N;
	N = in();
	vl A(N), B(N), C(N);
	rep(i, N)A[i] = in();
	rep(i, N)B[i] = in();
	rep(i, N)C[i] = in();
	sort(all(A));
	sort(all(C));

	ull ans = 0;
	each(b, B) {
		ll x = lower_bound(all(A), b) - begin(A);
		ll y = end(C) - upper_bound(all(C), b);
		ans += x * y;
	}
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main()
{
   int n;
   cin>>n;
   int a,b;
   int count=0;
   bool status = false;
   while(n--)
   {
      cin>>a>>b;
      if(a==b)
      {
          count++;
      }
      else
      {
          count=0;
      }
      if(count==3)
      {
          cout<<"Yes"<<endl;
          status = true;
         break; 
      }
   }
   if(status==false)
   {
       cout<<"No\n";
   }
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N , M;
    cin >> N >> M ;
    vector<ll> A;

    ll wholeA = 0 ;
    rep(i, N){
        ll inp; cin >> inp;
        A.pb(inp);
        wholeA += inp;
    }

    ll ans = 0 ;
    rep(i, N){
        if(A[i] * 4 * M >= wholeA){
            ans ++;
        }
    }
    
    if(ans >= M ) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 *  O(n)
 **/
#include <bits/stdc++.h>

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

using namespace std;

// data
int n;
const int MAX_N = 2e6, MAX_A = 1e4;
int A[MAX_N], B[MAX_N], C[MAX_A+1];

int main(){
    cin >> n;
    rep(i, n){
        cin >> A[i];
        C[A[i]]++;
    } 

    REP(i, 1, MAX_A+1){
        C[i] = C[i-1] + C[i];
    }

    rep(i, n){
        B[--C[A[i]]] = A[i];
    }
    rep(i, n){
        cout << B[i] << (i<n-1?" ": "\n");
    }
}


Measured memory_bytes: 18728
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  double a;
  while(cin>>a){
    double ans = a;
    for(int i=2;i<=10;i++) {
      if (i%2==1)
        a/=3;
      else
        a*=2;
      ans += a;
    }
    printf("%.8lf\n",ans);
  }
}

Measured memory_bytes: 0
#include<stdio.h>
int mini(int *price,int n)
{
  int min=price[0];
  int count=0;
  
  for(int i=1;i<n;i++)
  {
    if(price[i]<min)
    {
      min=price[i];
      count=i;
    }
  }
  price[count]=1001;
  
  return min;
}
  
  
  

int main(void)
{
  int total,n,k,i,*price;
  char nk[10];
  
  fgets(nk,sizeof(nk),stdin);
  sscanf(nk,"%d %d",&n,&k);
  
  price=(int *)malloc(sizeof(int)*n);
  
  for(i=0;i<n;i++)
  {
    scanf("%d",&price[i]);
  }
  
  total=0;
  
  for(i=0;i<k;i++)
  {
    total+=mini(price,n);
  }
  
  printf("%d",total);
  free(price);
  return 0;
}
  
  
  

Measured memory_bytes: 2172
def myAnswer(A:int,B:int,C:int,X:int,Y:int) -> int:
   ans = 0
   both = C * 2
   AB=A+B
   while X!=0 or Y!=0:
      if(X>=1 and Y >=1):
         ans += min(AB,both)
         X-=1
         Y-=1
      elif(X>=1 and Y == 0):
         ans += min(both,A)
         X -= 1
      else:
         ans += min(both,B)
         Y -= 1
   return ans


def modelAnswer():
   tmp=1
def main():
   A,B,C,X,Y=map(int,input().split())
   print(myAnswer(A,B,C,X,Y))
if __name__ == '__main__':
   main()

Measured memory_bytes: 3064
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanFloat64() float64 {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return float64(a)
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//•*¨*•.¸¸♪func•*¨*•.¸¸♪

type point struct {
	x float64
	y float64
}

func dist(p1,p2 point) float64 {
	return math.Sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y))
}

func circumcenter(a,b,c int, p []point) point {
	square := func (p1,p2 point) float64 {
		return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)
	}
	aa := square(p[b],p[c])
	bb := square(p[c],p[a])
	cc := square(p[a],p[b])
	deno := aa*(bb+cc-aa)+bb*(cc+aa-bb)+cc*(aa+bb-cc)
	x := (aa*(bb+cc-aa)*p[a].x+bb*(cc+aa-bb)*p[b].x+cc*(aa+bb-cc)*p[c].x)/deno
	y := (aa*(bb+cc-aa)*p[a].y+bb*(cc+aa-bb)*p[b].y+cc*(aa+bb-cc)*p[c].y)/deno
	
	return point{x,y}
}

func isStraight(a,b,c int, p []point) bool {
	square := func (p1,p2 point) float64 {
		return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)
	}
	aa := square(p[b],p[c])
	bb := square(p[c],p[a])
	cc := square(p[a],p[b])
	if aa*(bb+cc-aa)+bb*(cc+aa-bb)+cc*(aa+bb-cc)==0 {
		return true
	}
	return false
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer(make([]byte, 10000), 100000000)

	n := scanInt()
	
	p := make([]point, n)

	for i := 0; i < n; i++ {
		p[i] = point{scanFloat64(), scanFloat64()}
	}

	ca := make([]point, 0)

	for i := 0; i < n; i++ {
		for j := i+1; j < n; j++ {
			ca = append(ca,point{(p[i].x+p[j].x)/2,(p[i].y+p[j].y)/2})
			for k := j+1; k < n; k++ {
				if isStraight(i,j,k,p) {
					continue
				}
				
				ca = append(ca, circumcenter(i,j,k,p))

			}
		}
	}

	mi := float64(10000)

	for _, e := range ca {
		ma := float64(0)
		for i := 0; i < n; i++ {
			ma = math.Max(ma, dist(e,p[i]))
		}
		mi = math.Min(mi,ma)
	}

	fmt.Println(mi)

}


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

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

int main() {
  ll n, a, ans = 0;
  cin >> n;
  vector<ll> v(n);
  rep(i, n) {
    scanf("%d", &a);
    while (a % 2 == 0) {
      ans++;
      a /= 2;
    }
  }

  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

int main()
{
    ll n;
    cin >> n;
    cout << n*(n-1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int amp(int y,int z){
    y%=z;
    return y;
}
int main(void){
    int a,b,c,n=0;
    scanf("%d%d%d",&a,&b,&c);
    for(int x=a;x<=b;x++){
        if(amp(c,x)==0){
            n++;
        }
    }
    printf("%d\n",n);
    return 0;
}


Measured memory_bytes: 2096
//
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
int f(int n)
{
  switch(n){
  case 1:
    return 1;
    break;
  case 2:
    return 2;
    break;
  case 3:
    return 4;
    break;
  default:
    int a[30];
    a[0]=1;
    a[1]=2;
    a[2]=4;
    for(int i=3;i<n;++i){
      a[i]=a[i-1]+a[i-2]+a[i-3];
    }
    return a[n-1];
    break;
  }
}

int tenjyou(double n)
{
  if(n==(int)n){
    return (int) n;
  }else{
    return (int) n+1;
  }
}

int main()
{
  int n;
  int m=0;
  vector<int> answer;
  while(cin>>n&&n>0){
    double day,year;
    day=tenjyou(f(n)/10.0);
    year=tenjyou(day/365.0);
    answer.push_back(year);
    m+=1;
  }
  for(int i=0;i<m;++i){
    cout<<answer[i]<<endl;
  }
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  string s;
  ll start=LLONG_MAX, end=0;
  cin >> s;
  forll(i, 0, s.size()){
	if (s[i] == 'A')
	  start = min(start, i);
	else if (s[i] == 'Z')
	  end = max(end, i);
  }
  cout << end - start + 1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin >> a;
	if (a < 105)b = 0;
	else if(105 <= a && a < 135)b = 1;
	else if(135 <= a && a < 165)b = 2;
	else if(165 <= a && a < 189)b = 3;
	else if(189 <= a && a < 195)b = 4;
	else b = 5;
	cout << b << "\n";
}


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

# define x first    
# define y second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector         
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

typedef pair <int, int> pii; 
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();                   
  int n, m;
  cin >> n >> m;

  int mx = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char c; cin >> c;
      if (c == '#') {
        if (mx > j) {
          cout << "Impossible";
          return 0;
        }    
        mx = j;
      }
    }
  }   
  cout << "Possible";



  return 0;
}






// Coded by Z..



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sz 100005
#define faster_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;

int main()
{
    faster_io;
    int n,m;
    cin>>n>>m;
    if(n<m) cout<<0<<endl;
    else cout<<10<<endl;
    return 0;
}




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

int main() {
  int N, X;
  scanf("%d%d", &N, &X);

  vector<int> m(N, 0);
  for (int i = 0; i < N; i++) {
    scanf("%d", &m.at(i));
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    X -= m.at(i);
    ans++;
  }

  if (X > 0) {
    int min = *min_element(m.begin(), m.end());
    ans += X / min;
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 256
from collections import deque
k = int(input())

# 23から232(A),233(B),234(C)が作れる
# 20からは200(B),201(C)しか作れない
# 29からは298(A),299(B)しか作れない

queue = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
for i in range(k):
    x = queue.popleft()
    #print(x)
# (A)の場合
    if x % 10 != 0:
        queue.append(10 * x + (x % 10) - 1)
# (B)の場合
    queue.append(10 * x + x % 10)
# (C)の場合
    if x % 10 != 9:
        queue.append(10 * x + x % 10 + 1)

print(x)


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

typedef long long ll;

int a, b;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> b;
    cout << max(max(a + b, a - b), a * b) << endl;

    return 0;
}



Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main()
{
	long long int num, sum=0;
	cin>>num;
    int timearr[num];
	for(int i=0;i<num;i++)
	{
		cin>>timearr[i];
		sum+=timearr[i];
	}
	long int m;
	cin>>m;
	for(long long int i=1;i<=m;i++)
	{
		int p,x;
		cin>>p>>x;
		int val=sum-timearr[p-1]+x;
		cout<<val<<"\n";
	}
	
}


Measured memory_bytes: 256
month = [3, 1, 3, 2, 3, 2, 3, 3, 2, 3, 2, 3]

while True:
  m, d = map(int, input().split())
  if m == 0:
    break
  piv = 3
  for i in range(m-1):
    piv += month[i]
  piv += d
  piv %= 7
  if piv == 0:
    print("Sunday")
  elif piv == 1:
    print("Monday")
  elif piv == 2:
    print("Tuesday")
  elif piv == 3:
    print("Wednesday")
  elif piv == 4:
    print("Thursday")
  elif piv == 5:
    print("Friday")
  elif piv == 6:
    print("Saturday")


Measured memory_bytes: 5592
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

void IO(){
#ifndef ONLINE_JUDGE 
    freopen("in.txt", "r", stdin); 
    freopen("out.txt", "w", stdout); 
#endif 
}

const int MX=1e5+10;
int V,E;
vi adj[MX];
int memo[MX];

int solve(int u){
	if(memo[u]!=-1) return memo[u];
	int ans=-INF;
	if(sz(adj[u])==0) return 0;
	for(auto v: adj[u]) ans=max(ans,solve(v)+1);
	return memo[u]=ans;
}

int32_t main(){
   boost;
   IO();
   for(int i=0; i<MX; i++) memo[i]=-1;
   cin>>V>>E;
   for(int i=0; i<E; i++){
   	int u,v; cin>>u>>v;
   	adj[u].pb(v);
   }

   int ans=0;
   for(int i=1; i<=V; i++) ans=max(ans,solve(i));
   cout << ans << endl;

   return 0;
}


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

bool  check(vector<int> a,vector<int> b){

  if(a.size()>b.size()) return true;
  else if(a.size()<b.size()) return false;
  else{
    sort(a.begin(),a.end(),greater<int>());
    sort(b.begin(),b.end(),greater<int>());
    for(int i=0;i<a.size();++i){
      if(a[i]>b[i]){
        return true;
      }
      else if(a[i]<b[i]){
        return false;
      }
    }
    return true;
  }
}

int main(){

  vector<int> a={2,5,5,4,5,6,3,7,6};
  int N,M;
  cin>>N>>M;
  vector<int> b(M);
  for(int i=0;i<M;++i) cin>>b[i];

  vector<vector<int>> dp(N+1,vector<int>());

  dp[0].push_back(0);
  for(int i=1;i<N+1;++i){
    bool flag=false;
    for(int j=0;j<M;++j){
      if(i-a[b[j]-1]<0) continue;
      if(dp[i-a[b[j]-1]].size()==0) continue;
      if(!flag){
        dp[i]=dp[i-a[b[j]-1]];
        dp[i].push_back(b[j]);
        flag=true;
      }
      else{
        vector<int> ch=dp[i-a[b[j]-1]];
        ch.push_back(b[j]);
        if(check(ch,dp[i])) dp[i]=ch;
      }
    }
  }

  sort(dp[N].begin(),dp[N].end(),greater<int>());
  for(int i=0;i<dp[N].size()-1;++i) cout<<dp[N][i];
}

Measured memory_bytes: 163072
n = int(input())
ls = list(map(str,input().split()))
lso = ls[::2]
lse = ls[1::2]
if n % 2 == 0:
    ans = lse[::-1] + lso
else:
    ans = lso[::-1] + lse
p =" ".join(ans)
print(p)


Measured memory_bytes: 112472
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(int argc, char *argv[])
{
    int n, x[1001], y[1001];
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> y[i];
    }

    double p1, p2, p3, p_inf = 0.0;
    for (int i = 0; i < n; i++)
    {
        p1 += abs(x[i] - y[i]);
        p2 += pow(abs(x[i] - y[i]), 2);
        p3 += pow(abs(x[i] - y[i]), 3);
        if (p_inf < abs(x[i] - y[i]))
        {
            p_inf = abs(x[i] - y[i]);
        }
    }
    p2 = sqrt(p2);
    p3 = pow(p3, 1.0 / 3.0);
    
    cout << fixed << setprecision(6) << p1 << endl << p2 << endl << p3 << endl << p_inf << endl;

    return 0;
}


Measured memory_bytes: 3492
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N, M;
    cin >> N >> M;

    vector<ll> num(N, 1);
    vector<bool> pos(N, false);
    pos[0] = true;
    Rep (i, M) {
        ll x, y;
        cin >> x >> y;
        x--; y--;
        if (pos[x]) {
            pos[y] = true;
            if (num[x] == 1) {
                pos[x] = false;
            }
        }
        // for (auto e : pos) cout << e << " ";
        // cout << endl;
        num[x]--; num[y]++;
    }

    ll ans = 0;
    Rep (i, N) {
        if (pos[i]) ans++;
    }

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

Measured memory_bytes: 1024
s = input()
ans = "Yes"
for i in range(0,len(s)):
    if(i % 2 == 0):
        if(s[i] != 'R' and s[i] != 'U' and s[i] != 'D'):
            ans = "No"
            break
    else:
        if(s[i] != 'L' and s[i] != 'U' and s[i] != 'D'):
            ans = "No"
            break
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll N, A, f[1000001] = {}, c[1000001] = {}, ans = 0;

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
	return modpow(a, mod - 2, mod);
}

int main() {
	cin >> N;
	rep(i, N) {
		cin >> A;
		f[A]++;
	}
	for (int i = 1; i <= 1000000; i++)c[i] = modinv(i, 998244353);
	for (int i = 1; i <= 1000000; i++) {
		for (int j = i * 2; j <= 1000000; j += i) {
			c[j] += 998244353-c[i];
			c[j] %= 998244353;
		}
	}
	for (int i = 1; i <= 1000000; i++) {
		ll sum = 0;
		ll sqSum = 0;
		for (int j = i; j <= 1000000; j += i) {
			sum += j * f[j];
			sum %= 998244353;
			sqSum += (((ll)j * j) % 998244353) * f[j];
			sqSum %= 998244353;
		}
		sum = (c[i] * ((((sum * sum - sqSum + 998244353) % 998244353) * modinv(2, 998244353)) % 998244353)) % 998244353;
		ans += sum;
		ans %= 998244353;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15872
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

#define bitcount(n) __builtin_popcount(n)

#define debug(n) cout << n << endl;

#define PREC(n) setprecision(n)
#define DOTPREC(n) fixed << setprecision(n)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false); cin.tie(0)

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

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

const ll MOD = 1000000007;

int a, b, c;

int main(void)
{
    cin >> a >> b >> c;

    int large = std::max(std::max(a, b), c);
    int total = 0;

    if (large == a) {
        total = b + c;
    }
    else if (large == b) {
        total = c + a;
    }
    else /* if (large == c) */ {
        total = a + b;
    }

    if (large == total) {
        debug("Yes");
    }
    else {
        debug("No");
    }

    return 0;
}


Measured memory_bytes: 256
// ACM-ICPCアジア地区予選2013 A. Equal Sum Sets

#include <iostream>

using namespace std;

int main(){
	int n, k, s;
	while(cin >> n >> k >> s && n){
		int res = 0;
		for(int i=0;i<(1<<n);i++){
			int cnt = 0, sum = 0;
			for(int j=0;j<n;j++){
				if((1<<j)&i){
					cnt++;
					sum += j+1;
				}
			}
			if(k==cnt && s==sum) res++;
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 1160
import java.util.Arrays;
import java.util.Scanner;

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

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

        int maxDistance = 0;
        maxDistance = Math.max(maxDistance, a[1] - a[0]);
        for(int i = 1; i<n; i++){
            maxDistance = Math.max(maxDistance, a[i] - a[i-1]);
        }

        maxDistance = Math.max(maxDistance, k-a[n-1]+a[0]);

        int ans = 0;
        ans = k-maxDistance;
        System.out.println(ans);

    }
}

Measured memory_bytes: 78352
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v) { cout << v << endl; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

int n;
vector<ll> A(100);
// ll dfs(int i = 0, ll m = 1000, ll s = 0) {
//   if (i==n) return m;
//   
// }


int main() {
  cin >> n;
  loop(i,0,n) in(A[i]);
  ll m = 1000;
  ll s = 0;
  ll prev = A[0];
  bool up = false;
  loop(i,1,n) {
    // print(m);
    if (prev == A[i]) {
      continue;
    }
    
    if (up) {
      // 上昇継続なら待ち.
      if (prev < A[i]) {
        prev = A[i];
        continue;
      }
      
      // 次に下降に転じるならすべて売る.
      m += s*prev;
      s = 0;
      up = false;
      // print(vector { (ll)(i-1), m, s });
      prev = A[i];
      continue;
    }
    
    // down
    
    // 上昇に転じるなら変えるだけ買う.
    if (prev < A[i]) {
      ll num = m / prev;
      m -= num*prev;
      s += num;
      up = true;
      // print(vector { (ll)(i-1), (ll)num, m, s });
      prev = A[i];
      continue;
    }
    
    // 下降継続ならステイ
    prev = A[i];
  }
  
  m += s * A[n-1];
  s = 0;
  // print(vector { (ll)n, m, s });
  print(m);
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define int long long
int nonempty[1000];
int empty[1000];
vector<int> g[1000];
string type[1000];
int MOD = 1e9 + 7;

void dfs(int x){
	// preprocess
	for(int j = 0 ; j < g[x].size() ; j++){
		dfs(g[x][j]);			
	} 
	if( type[x][0] != 'E' ){
		// main process
		empty[x] = type[x].back() == '?';
		if( type[x][0] == 'R' ){
			for(int i = 1 ; i < (1<<g[x].size()) ; i++){
				int emp = 1;
				int sub = 1;
				for(int j = 0 ; j < g[x].size() ; j++){
					if( i >> j & 1 ){
						emp *= empty[g[x][j]];
						sub *= empty[g[x][j]] + nonempty[g[x][j]];
						sub %= MOD;
					}
				}
				//sub -= emp;
				empty[x] |= emp;
				nonempty[x] += sub;
				nonempty[x] %= MOD;
			}
		}else{
			for(int j = 0 ; j < g[x].size() ; j++){
				empty[x] |= empty[g[x][j]];
				nonempty[x] += nonempty[g[x][j]];
				nonempty[x] %= MOD;
			}
		}
	}else{
		empty[x] = type[x].back() == '?';
		int sub = 1;
		int emp = 1;
		for(int j = 0 ; j < g[x].size() ; j++){
			emp *= empty[g[x][j]];
			sub *= (empty[g[x][j]]+nonempty[g[x][j]]);
			sub %= MOD;
			
		}
		nonempty[x] = sub;
		
		
	}
	//cout << x+1 << "  emp:" << empty[x] << " nonemp:" << nonempty[x] << "(" << type[x] << endl;
	
	
	
}
signed main(){
	int N;
	cin >> N;
	for(int i = 0 ; i < N ; i++)
		cin >> type[i];
	for(int i = 0 ; i < N - 1 ; i++){
		int s,t;
		cin >> s >> t;
		--s,--t;
		g[s].push_back(t);
	}
	dfs(0);
	cout << ((nonempty[0] + empty[0])%MOD+MOD)%MOD << endl;
	
	

}

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

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var a = new int[n];
            for (int i = 0; i < n; i++) a[i] = int.Parse(Console.ReadLine().Trim());
            Array.Sort(a);
            a[0] =0;  a[n - 1] = 0;
            Console.WriteLine(a.Sum() / (n - 2));
        }
    }
}

Measured memory_bytes: 9612
#

import sys
input=sys.stdin.readline

def main():
    N,M=map(int,input().split())
    lr=[tuple(map(int,input().split())) for i in range(M)]
    imos=[0]*(N+2)
    cnt=0
    for i in lr:
        imos[i[0]]+=1
        imos[i[1]+1]-=1
    for j in range(N+1):
        imos[j+1]+=imos[j]
    for i in imos:
        if i == M:
            cnt+=1
    print(cnt)
    
if __name__=="__main__":
    main()


Measured memory_bytes: 20568
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
AB.sort()
ans = 0
while M > 0:
    ab = AB[0]
    if ab[1] <= M:
        M-= ab[1]
        ans += ab[0] * ab[1]
        AB.pop(0)
    else:
        ans += ab[0] * M
        M -= M
print(ans)        

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

int main (){
    int N;
    cin >> N;
    int A[N];
    int V,B = 0;

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

    for(int i=0; i<N; i++){
        if(A[i] % 2 == 0){
            V = V+1;
            if(A[i] % 3 == 0 || A[i] % 5 == 0){
                B = B+1;
            }
        }
    }

    if(B == V){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }

    return 0;
}

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


int main(){
    int N,D;
    int X[10][10];
    cin >> N >> D;
    for(int i=0; i<N; i++){
        for(int j=0; j<D; j++){
            cin >> X[i][j];
        }
    }

    int count = 0;
    int c = 0;

    double distance[500];
    for(int a=0; a<N; a++){
        for(int b=a+1; b<N; b++){
            int sum = 0;
            for(int d=0; d<D; d++){
                sum += pow((X[a][d]-X[b][d]),2);
            }
            distance[c] = sqrt(sum);
            if(distance[c] == (int)distance[c]){
                count++;
            }
            c++;
        }
    }

    cout << count;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <algorithm>


int main() {
	int N;
	std::cin >> N;
	int a[N][3];
	for (int i = 0; i < N; ++i) {
		std::cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	
	int dp[N][3];
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			dp[i][j] = 0;
		}
	}
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	for (int i = 1; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			dp[i][j] = std::max(
				dp[i - 1][(j + 1) % 3] + a[i][j],
				dp[i - 1][(j + 2) % 3] + a[i][j]
			);
		}
	}
	std::cout << std::max({
		dp[N - 1][0],
		dp[N - 1][1],
		dp[N - 1][2],
	}) << std::endl;
	
	return 0;	
}


Measured memory_bytes: 5476
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

using I = int64_t;
template <class F>
I lower_bound(I i0, I i1, F f) {
    while (i0 < i1) {
        I i = (i0 + i1) / 2;
        if (f(i)) i1 = i; else i0 = i + 1;
    }
    return i0;
}

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

    int n, k;
    cin >> n >> k;

    vector<int64_t> w(n);
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> w[i] >> d[i];
    }

    I x = lower_bound(0, (I)2e+18, [&](I x) {
        int64_t s = 0;
        for (int i = 0; i < n; i++) {
            if (x <= w[i]) continue;
            s += (x - w[i] + d[i] - 1) / d[i];
        }
        return s >= k;
    });
    cout << x - 1 << endl;

    return 0;
}

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

int n, m, q, ans;
vector<int> a, b, c, d;
void dfs(vector<int> A){
  if(A.size() == n+1){
    int now = 0;
    rep(i, q){
      if(A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans , now);
   	return;
  }
    
  A.push_back(A.back());
  while(A.back() <= m){
    dfs(A);
    A.back()++;
  }
}
  

int main(){
  cin >> n >> m >> q;
	 a = b = c = d = vector<int> (q);
  rep(i, q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  
  dfs(vector<int> (1, 1));
  
  cout << ans << endl;  
  return 0;
}

Measured memory_bytes: 3608
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int n;
bool prime[105000];
int ans[10500];
int main()
{
  for(int i = 2;i <105000;i++){
    prime[i] = true;
  }
  prime[0] = false;
  prime[1] = false;
  int k = 1;
  ans[0] = 0;
  for(int i = 2;i<105000;i++){
    if(prime[i]){
      ans[k] = ans[k-1]+i;
      k++;
      for(int j =2*i;j <105000;j+=i){
	prime[j] = false;
      }
    }
  }
  while(cin>>n,n){
    
    cout <<ans[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b;
    print((a-1)*(b-1));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define DEBUG_MODE
#define endl '\n'
#ifdef DEBUG_MODE
#define DEBUG(X) debug_func(X, #X)
#define DEBUG_ENDL endl
#define DEBUG_SEPARATOR_LINE cout<<"=================\n"
#else
#define DEBUG(X) 0
#define DEBUG_ENDL 0
#define DEBUG_SEPARATOR_LINE 0
#endif
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "")
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; }
template <typename T>
void debug_func(const T &t, const string &s = "") {
    debug_func_preffix(s);
    cout << t << DEBUG_ENDL_S(s);
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
    debug_func_preffix(s);
    cout << "(";
    debug_func(p.first);
    cout << ", ";
    debug_func(p.second);
    cout << ")" << DEBUG_ENDL_S(s);
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
    for(ll i = 0; i < v.size(); i++) {
        string t = s + "[" + to_string(i) + "]";
        debug_func(v[i], t);
    }
}

int main() {
    ll N;
    cin >> N;
    V<ll> A(N);
    for(ll &e : A) cin >> e;
    ll ans = 0;
    A.push_back(5e15);
    for(ll i = 0; i < N; i++) {
        if(A[i] == i + 1) {
            swap(A[i], A[i + 1]);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    // Your code here!"
    unsigned long long int n,sum=0;
    cin >> n;
    for(int i=1; i<=n; i++){
        if(0 != i%3 && 0 != i%5){
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3192
# AtCoder Beginner Contest 131
# B - Bite Eating

N,L=map(int,input().split())
minabs=10**9
apples=[]
for i in range (N):
    t=L+i
    apples.append(t)
    if abs(t)<abs(minabs):
        minabs=t

full=sum(apples)

print(full-minabs)

Measured memory_bytes: 9140
#include<stdio.h>

int pos[][3]={
	{1,2,3},{1,3,5},{1,4,2},{1,5,4},
	{2,1,4},{2,3,1},{2,4,6},{2,6,3},
	{3,1,2},{3,2,6},{3,5,1},{3,6,5},
	{4,1,5},{4,2,1},{4,5,6},{4,6,2},
	{5,1,3},{5,3,6},{5,4,1},{5,6,4},
	{6,2,4},{6,3,2},{6,4,5},{6,5,3},
};

int f(int*d1,int*d2){
	for(int i=1;i<=6;i++)scanf("%d",d1+i);
	for(int i=1;i<=6;i++)scanf("%d",d2+i);
	for(int i=0;i<24;i++){
		int flag=1;
		for(int j=0;j<3;j++)flag&=d1[j+1]==d2[pos[i][j]];
		for(int j=3;j<6;j++)flag&=d1[j+1]==d2[7-pos[i][5-j]];
		if(flag)return 1;
	}
	return 0;
}

int a[110][7];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)for(int j=1;j<=6;j++)scanf("%d",&a[i][j]);
	for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
		if(f(a[i],a[j])){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}


Measured memory_bytes: 2112
n, m = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(m)]

from collections import defaultdict
g = defaultdict(list)
for x, y in xy:
    x, y = x - 1, y - 1
    g[x].append(y)
    g[y].append(x)

visited = [0] * n
ans = 0

for i in range(n):
    if visited[i] == 0:
        q = [i]
        visited[i] = 1
        s = set([i])
        while q:
            cur = q.pop()
            for target in g[cur]:
                if visited[target] == 0:
                    visited[target] = 1
                    q.append(target)
                    s.add(target)

        ps = set()
        for j in s:
            ps.add(p[j] - 1)

        intersect = s & ps
        ans += len(list(intersect))
print(ans)


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

int n,a,b,x,d[200009];
vector<int> e[200009];

int bfs(int s){
    rep(i,n+1)d[i]=inf;
    d[s]=0;
    queue<int> que;
    que.push(s);
    int now;
    while(!que.empty()){
        now=que.front();
        que.pop();
        rep(i,e[now].size()){
            if(d[e[now][i]]!=inf)continue;
            d[e[now][i]]=d[now]+1;
            que.push(e[now][i]);
        }
    }
    x=now;
    return d[now];
}

int main(){
    cin>>n;
    rep(i,n-1){
        cin>>a>>b;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    bfs(1);
    cout<<(bfs(x)%3!=1?"First\n":"Second\n");
}

Measured memory_bytes: 13556
N = int(input())
out = []
U = 0
D = 0
t = 1
now = 0

if N>0:
    while now!=N:
        X = (N-D)%(2**t)
        if X!=0 and X<=(2**t)//2:
            out.append(1)
        else:
            out.append(0)
        if t%2==1:
            D += 2**(t-1)
        now = 0
        for i in range(len(out)):
            now += out[i]*(-2)**i
        t+=1
if N<0:
    while now!=N:
        X = (U-N)%(2**t)
        if X!=0 and X<=(2**t)//2:
            out.append(1)
        else:
            out.append(0)
        if t%2==0:
            U += -1*2**(t-1)
        now = 0
        for i in range(len(out)):
            now += out[i]*(-2)**i
        t+=1
if N==0:
    out = [0]

print("".join(list(map(str,out[::-1]))))

Measured memory_bytes: 38384
/*
 * Owner   : Tatsuhiro Hashimoto
 * Created : 2020-04-22 (Wed)
 */

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

#define endl "\n"
#define FSP(n) cout << fixed << setprecision(n);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
static inline ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b);}
static inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
#define prepare cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);

signed main() {
    prepare
    int K = 0, N = 0;
    cin >> K >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    A.push_back(A[0] + K);
    int tmp = 0;
    for (int i = 0; i < N; ++i) {
        tmp = max(tmp, A[i + 1] - A[i]);
    }
    cout << K - tmp << endl;
}

Measured memory_bytes: 1792
kyu = int(input())

if 400 <= kyu  <= 599:
    print(8)
elif 600 <= kyu  <= 799:
    print(7)
elif 800 <= kyu  <= 999:
    print(6)
elif 1000 <= kyu  <= 1199:
    print(5)
elif 1200 <= kyu  <= 1399:
    print(4)
elif 1400 <= kyu  <= 1599:
    print(3)
elif 1600 <= kyu  <= 1799:
    print(2)
else:
    print(1)

Measured memory_bytes: 9096
import java.util.*;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int sum = 0;
		
		for(char c : N.toCharArray()) {

			sum += Character.getNumericValue(c);
          	
			if(sum>=9){
				sum %= 9;
			}
		}
      
       if(sum==0){
			System.out.println("Yes");
       }else{
		System.out.println("No");
	   }
		
		return;
	}

}


Measured memory_bytes: 40508