akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias C = Tuple!(int, "size", int, "p");

void solve(int N, int M)
{
    auto CS = new int[](N);
    foreach (s; readln.split.to!(int[])[1..$]) CS[s-1] = 0;
    foreach (s; readln.split.to!(int[])[1..$]) CS[s-1] = 1;
    foreach (s; readln.split.to!(int[])[1..$]) CS[s-1] = 2;

    int s, min_s, max_s = 3^^N-1;
    foreach_reverse (c; CS) {
        s *= 3;
        s += c;
    }
    if (s == min_s || s == max_s) {
        writeln(0);
        return;
    }
    auto memo = new bool[](3^^N);
    memo[s] = true;
    auto ss = [s];
    foreach (cnt; 1..M+1) {
        int[] nss;
        foreach (x; ss) {
            int a = -1, b = -1, c = -1;
            foreach (i; 0..N) {
                CS[i] = x%3;
                x /= 3;
                switch (CS[i]) {
                    case 0: a = i.to!int; break;
                    case 1: b = i.to!int; break;
                    default: c = i.to!int;
                }
            }
            int add() {
                int y;
                foreach_reverse (x; CS) {
                    y *= 3;
                    y += x;
                }
                return y;
            }
            int r = -1;
            if (a > b) {
                CS[a] = 1;
                r = add();
                CS[a] = 0;
            } else if (a < b) {
                CS[b] = 0;
                r = add();
                CS[b] = 1;
            }
            if (r != -1 && !memo[r]) {
                if (r == min_s || r == max_s) {
                    writeln(cnt);
                    return;
                }
                nss ~= r;
                memo[r] = true;
            }
            r = -1;
            if (b > c) {
                CS[b] = 2;
                r = add();
                CS[b] = 1;
            } else if (b < c) {
                CS[c] = 1;
                r = add();
                CS[c] = 2;
            }
            if (r != -1 && !memo[r]) {
                if (r == min_s || r == max_s) {
                    writeln(cnt);
                    return;
                }
                nss ~= r;
                memo[r] = true;
            }
        }
        ss = nss;
    }
    writeln(-1);
}

void main()
{
    for (;;) {
        auto nm = readln.split.to!(int[]);
        auto N = nm[0];
        auto M = nm[1];
        if (N == 0 && M == 0) break;
        solve(N, M);
    }
}


Measured memory_bytes: 17304
#include <stdio.h>
int main(){
	int a,b;
	scanf("%d%d", &a, &b);
	if(a!=1&&b==1)
		printf("Bob");
	if(a==1&&b!=1)
		printf("Alice");
	if(a==b)
		printf("Draw");
	else if(a!=1&&b!=1)
	{
		if(a>b)
			printf("Alice");
		else
			printf("Bob");
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)

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

Measured memory_bytes: 256
A = list(input())
B = list(input())
C = list(input())

A = A[::-1]
B = B[::-1]
C = C[::-1]

next = A.pop()

while 1:    
  if next=='a':
    if len(A)==0:
      print('A')
      break
    next = A.pop()
  elif next=='b':
    if len(B)==0:
      print('B')
      break
    next = B.pop()
  else:
    if len(C)==0:
      print('C')
      break
    next = C.pop()
    


Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

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

int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> s(H, vector<char>(W));
  int sharp=0;
  rep(i,H)rep(j,W){
    cin >> s[i][j];
    if(s[i][j]=='#')
      sharp++;
  }
  vector<vector<int>> route(H, vector<int>(W,-1));
  route[0][0]=1;
  queue<pair<int, int>> que;
  que.push({0,0});
  while(!que.empty()){
    pair<int, int> p=que.front();
    que.pop();
    rep(i,4){
      if(p.first+dx[i]<0 || p.first+dx[i]>=H || p.second+dy[i]<0 || p.second+dy[i] >=W)
        continue;
      if(s[p.first+dx[i]][p.second+dy[i]]=='.' && route[p.first+dx[i]][p.second+dy[i]]==-1){
        route[p.first+dx[i]][p.second+dy[i]]=route[p.first][p.second]+1;
        que.push({p.first+dx[i],p.second+dy[i]});
      }
    }
  }
  if(route[H-1][W-1]==-1){
    cout << -1 << endl;
    return 0;
  }
  cout << H*W-route[H-1][W-1]-sharp << 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=3005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;ll T;cin>>N>>T;
    ll ma=0,fi=0;
    
    for(int i=0;i<N;i++){
        ll a;cin>>a;
        fi+=a;
        ma=max(ma,a);
        if(fi>T){
            cout<<1<<endl;
        }else{
            ll rem=T-fi+1;
            cout<<1+(rem+ma-1)/ma<<endl;
        }
    }
}




Measured memory_bytes: 3216
from collections import Counter
N = int(input())
Ds = list(map(int, input().split()))

if Ds[0] != 0:
    print(0)
    exit()
Ds = sorted(Ds[1:])
c = Counter(Ds)
M = 998244353

r = p = i = 1
x = c.get(i)
while x:
    N -= x
    r = r * pow(p, x, M) % M
    i += 1; p = x; x = c.get(i)
print((r,0)[N>1])

Measured memory_bytes: 19920
A, B, C, X, Y = map(int,input().split())

if A+B < 2*C:
    ans = (A*X + B*Y)
elif A > 2*C and B > 2*C:
    ans = 2*C*max(X,Y)
elif A > 2*C:
    ans = 2*C*X + B*max(0,(Y-X))
elif B > 2*C:
    ans = 2*C*Y + A*max(0,X-Y)
else:
    ans = 2*C*min(X,Y) + A*max(0,X-Y) + B*max(0,Y-X)

print(ans)

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

int main(){
    int N,A,B; cin >> N >> A >> B;
    int Sum=0;
    for (int i=1; i<=N; i++){
        int sum=0;
        string str=to_string(i);
        for (int j=0; j<str.size(); j++){
            sum+=str[j]-'0';
        }
        if(A<=sum && sum <=B) Sum+=i;
    }
    cout << Sum;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
a1=min(h*(w%3!=0),w*(h%3!=0))
a2=10**6
a3=10**6
for i in range(1,h):
  mx=max(w*i,(w//2)*(h-i),((w+1)//2)*(h-i))
  mn=min(w*i,(w//2)*(h-i),((w+1)//2)*(h-i))
  a2=min(a2,mx-mn)
for i in range(1,w):
  mx=max(h*i,(h//2)*(w-i),((h+1)//2)*(w-i))
  mn=min(h*i,(h//2)*(w-i),((h+1)//2)*(w-i))
  a3=min(a3,mx-mn)
print(min(a1,a2,a3))


Measured memory_bytes: 9236
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define rep(i, a, b) for(ll i = a; i < b; ++i)
using namespace std;
typedef long long ll;
typedef vector<ll> vll;


int main()
{
	FIO;
    ll a, b; cin >> a >> b;
	cout << a*b << '\n';
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define inf 10000000000
using namespace std;
using ll = long long;
int main()
{
    int h,n;
    cin >> h >> n;
    vector<int> A(n),B(n);
    rep(i,n){
        int a, b;
        cin >> a >> b;
        A[i]=a,B[i]=b;
    }
    vector<ll> dp(h+1, 1'000'000'000'000);
    dp[0] = 0;
    for (int j = 0; j <= h; j++)
    {
        if (dp[j] == 1'000'000'000'000){
            continue;
        }
        rep(i,n){
            if (j + A[i] <= h)
                dp[j + A[i]] = min(dp[j + A[i]], dp[j] + B[i]);
            else{
            dp[h] = min(dp[h], dp[j] + B[i]);
            }
        }
    }
    cout << dp[h] << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main() {
	int n;
	cin>>n;
	long long arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}

 
    long long result = arr[0]; 
    for (int i = 1; i < n; i++) 
        result = gcd(arr[i], result); 
  
    cout<<result; 

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int sum=0,fushu=1;
	char c=getchar();
	while(!isdigit(c)){
		if(c=='-') fushu=-fushu;
		c=getchar();
	}
	while(isdigit(c)){
		sum=sum*10+(c^48);
		c=getchar();
	}
	return sum*fushu;
}
void write(int x){//只能输出非负整数！！！比赛的时候看清楚！！！ 
	if(x>=10) write(x/10);
	putchar(x%10+48);
}
inline void writeln(int x){
	write(x);
	putchar('\n');
}
int const maxn=300000;
int n,k,a[maxn];
signed main(){
	n=read(),k=read();
	n=pow(2,n);
	if(k>n-1){
		printf("-1\n");
		return 0;
	}
	if(k==0){
		for(int i=0;i<2*n;i++)
		  write(i/2),putchar(' ');
		return 0;
	}
	a[n]=a[n*2]=k;
	for(int i=1,j=0;i<n;i++,j++){
		if(j==k) j++;
		a[i]=a[2*n-i]=j;
	}
	int ans=0;
	for(int i=n;i<=n*2;i++)
	  ans^=a[i];
	if(ans!=k){
		printf("-1\n");
		return 0;
	} 
	for(int i=1;i<=n*2;i++)
	  write(a[i]),putchar(' ');
	return 0;
}

Measured memory_bytes: 3840
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
int read(){
	register int x = 0;
	register char f = 1, ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f ^= 1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
	return f ? x : -x;
}
int n, m;
int main(){
	n = read();
	for (register int i = 1; i <= 9; ++i)
		for (register int j = 1; j <= 9; ++j)
			if (i * j == n) return puts("Yes"), 0;
	puts("No");
}

Measured memory_bytes: 128
use std::str::FromStr;
use std::io::stdin;

fn main() {
    let (k, a, b) = {
        let vec = read_vec::<i64>();
        (vec[0], vec[1], vec[2])
    };
    let mut c = 0_i64;
    let mut bis = 1_i64;
    while c < k {
        if k - c >= 2 && bis >= a && b - a >= 3 {
            bis -= a;
            bis += b;
            c += 2;
        } else {
            bis += 1;
            c += 1;
        }
    }
    println!("{}", bis);
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().split_whitespace()
        .map(|i| i.parse().ok().unwrap()).collect()
}

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

int main(void){
	long long N;
	cin >> N;
	long long i;
	int temp,tempans;
	int ans = std::to_string(N).length();
	for(i=1;i*i<=N;i++){
		if(N%i!=0)continue;
		long long B =N/i;
		temp = std::max(i,B);
		tempans = std::to_string(temp).size();
		if(ans>tempans)ans=tempans;
	}
	cout << ans;
	return 0;
}

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

int main(){

    int n;
    cin>>n;

    string s;
    set<string> a;
    for(int i=0;i<n;i++){
        cin>>s;
        a.insert(s);
    }
    cout<<a.size()<<endl;








    return 0;
}

Measured memory_bytes: 19124
X, K, D = map(int, input().split())

minus = X < 0
if minus:
  X = -X

R = X // D

if K <= R:
  result = X - D * K
else:
  n = K - R
  n %= 2
  P = X - D * R
  if n == 0:
    result = P
  else:
    result = abs(P - D)
    

print(result)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define pb push_back
#define sz(v) (v).size()
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define fi first
#define se second
#define inf 1000000000
#define mod 1000000007
using namespace std;
template <class T> void chmax(T &x,T y){x=x>y?x:y;return;}
template <class T> void chmin(T &x,T y){x=x<y?x:y;return;}
typedef long long ll;
typedef unsigned long long ull;

string s;

int f(string str)
{
	for(int i=0;i<sz(str);i++)
	{
		int j=sz(str)-i-1;
		if(str[i]!=str[j]) return 0;
	}
	return 1;
}

int main()
{
	cin>>s;
	int n=sz(s);
	s=" "+s;
	if(f(s.substr(1,n))&&f(s.substr(1,(n-1)/2))&&f(s.substr((n+3)/2,n-(n+3)/2+1))) 
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;
    vector<int> L(n);
    REP(i, n) cin >> L[i];

    sort(ALL(L));
    
    int res = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < i; j++) {
            for(int k = 0; k < j; k++) {
                if(L[i] != L[j] && L[j] != L[k] && L[k]+L[j] > L[i]) res++;
            }
        }
    }

    cout << res << endl;

    return 0;
}

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

int main() {
  long double r; cin >> r;
  cout << fixed << setprecision(10) << r * 2 * 3.14159265358979323846 << endl;
  return 0;
}

Measured memory_bytes: 3796
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> aoeui, pair<int, int> boeui){return aoeui.se < boeui.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; i++)
#define foris(i, a, b) for(ll i = a; i < b; i++)
#define forise(i, a, b) for(ll i = a; i <= b; i++)
#define ford(i, n) for(ll i = n; i >= 0; i--)
#define fords(i, a, b) for(ll i = a; i >= b; i--)
#define fordse(i, a, b) for(ll i = a; i > b; i--)
#define forr(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

int R;

int main() {
  io();
  
  cin >> R;
  R = 3*R*R;
  cout << R;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600

#define MAX_PRIME 1000000

vector<int> primes;

// sieve of Erastosthenes
inline void prime_list(){
  vector<bool> isPrime(MAX_PRIME+1, true);
  const int sz = MAX_PRIME;
  isPrime[0]=isPrime[1]=false;
  for(int i=4;i<=sz;i+=2) isPrime[i]=false;
  primes.pb(2);
  for(int i=3; i<=sz; i+=2){
    if(isPrime[i]){
      primes.pb(i);
      for(long j=(long)i*i; j<=sz; j+=i) isPrime[j]=false;
    }
  }
}

int main(){
  prime_list();
  int d;
  while(cin>>d){
    cout << upper_bound(all(primes), d) - primes.begin() << endl;
  }

  return 0;
}

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

using namespace std;
const int N = 100010;
int _w;

int n, a[N], ans;

int main() {
	cin >> n;
	for( int i = 1; i <= n; ++i )
		cin >> a[i];
	int state = 0;
	for( int i = 2; i <= n; ++i )
		if( state == 0 ) {
			if( a[i] > a[i-1] ) state = 1;
			else if( a[i] < a[i-1] ) state = -1;
		} else if( state == 1 ) {
			if( a[i] < a[i-1] )
				state = 0, ++ans;
		} else if( state == -1 ) {
			if( a[i] > a[i-1] )
				state = 0, ++ans;
		}
	++ans;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define viii vector <pair<ll,pair<ll,ll> > >
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<endl
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define endl "\n"
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
bool compare(pair<ll,string> p1,pair<ll,string> p2){
return p2.fi>p1.fi;
}
void solve(){
ll n,k;
cin>>n>>k;
bool vis[n+1]={0};
fr(i,0,k){
ll d,a;
cin>>d;
fr(i,0,d){
cin>>a;
vis[a]=1;
}
}
ll cnt=0;
fr(i,1,n+1){
if(vis[i]==0) cnt++;
}
cout<<cnt<<endl;
}
int main()
{   fast;
    ll t=1;
    //cin>>t;
    fr(zz,1,t+1){
    solve();
    }
}


Measured memory_bytes: 3652
menu=[]
5.times{
    menu << gets.to_i
}

time=0

menu.map{|i| i%10}.sort.each{|a|
    if a.nonzero?
        time=a-10
        break
    end
}

time+=menu.map{|i| (i.to_f/10).ceil*10}.inject(:+)

puts time

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////


int main(){fastio
    string s;cin>>s;
    if(s.size()==3)reverse(all(s));
    cout<<s;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  string s, p;
  cin >> s >> p;
  ll n = s.size(), m = p.size();
  string ans = "No";
  rep(i, n) {
    ll tmp = 0;
    rep(j, m) {
      if (i+j >= n) {
        if (s.at((i+j)%n) == p.at(j)) tmp++;
      } else {
        if (s.at(i+j) == p.at(j)) tmp++;
      }
    }
    if (tmp == m) ans = "Yes";
  }
  cout << ans << endl;
}


Measured memory_bytes: 3184
#include<iostream>
    #include<algorithm>
    using namespace std;
     
    int main() {
        string s;
        cin >> s;
        int k=0,sn;
        for (auto c:s) {
            if (c=='S') {++sn;}
            else {if (sn>0){--sn;k+=2;}}
        }
        cout << s.length()-k << endl;
        return 0;
    }

Measured memory_bytes: 640
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
cook_time = [A,B,C,D,E]
muda = [10-i%10 if i%10!=0 else 0 for i in cook_time]
cook_time_muda = list(zip(cook_time,muda))
cook_time_muda.sort(key=lambda x:x[1])
time = 0
for i in cook_time_muda:
    time = time + i[0]+i[1]
time = time - i[1]
print(time)

Measured memory_bytes: 3064
using System;

class program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split();
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = a * b;
        string answer;
        if (c % 2 == 0)
        {
            answer = "Even";
        }
        else
        {
            answer = "Odd";
        }

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 13140
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        for (int i = 0; i < H; i++) {
            String line = sc.next();
            int x = -1;
            for (int j = 0; j < W; j++) {
                if (line.charAt(j) == 'c') {
                    x = 0;
                } else {
                    if (x >= 0) x += 1;
                }
                if (j > 0) {
                    System.out.print(" ");
                }
                System.out.print(x);
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 34492
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var tree = Enumerable.Range(0, (int)N)
                .Select(x => new List<Node>())
                .ToArray();

            for (int i = 0; i < N - 1; i++)
            {
                var inputs = ReadLongs();

                // indexに変換
                var a = inputs[0] - 1;
                var b = inputs[1] - 1;

                var node = new Node
                {
                    Index = i,
                    A = a,
                    B = b,
                };

                tree[a].Add(node);
                tree[b].Add(node);
            }

            var nodeColors = new long[N - 1];
            var queue = new Queue<KeyValuePair<long, long>>();// valueが親Nodeの色とする
            queue.Enqueue(new KeyValuePair<long, long>(0, 0));
            while (queue.Count > 0)
            {
                var q = queue.Dequeue();
                var drawColor = 1;
                foreach (var node in tree[q.Key])
                {
                    if (nodeColors[node.Index] == drawColor || q.Value == drawColor) drawColor++;
                    nodeColors[node.Index] = drawColor;

                    var nextPoint = node.A == q.Key ? node.B : node.A;
                    // 二重カウントにならないように除外する
                    tree[nextPoint].RemoveAll(x => x.Index == node.Index);
                    queue.Enqueue(new KeyValuePair<long, long>(nextPoint, drawColor));

                    drawColor++;
                }
            }

            var colorCount = nodeColors.Max();
            var sb = new StringBuilder();
            sb.AppendLine(colorCount.ToString());
            foreach (var c in nodeColors)
            {
                sb.AppendLine(c.ToString());
            }

            return sb.ToString().Trim();
        }

        class Node
        {
            public long Index { get; set; }
            public long A { get; set; }
            public long B { get; set; }
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 34044
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

typedef int keytype;

//quicksort(<#keytype *a#>, <#int first#>, <#int last#>)

void quicksort(keytype a[], int first, int last){
    int i, j;
    keytype x, t;
    
    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int gcd(int x, int y){
    if (y == 0) return x;
    else        return gcd(y, x % y);
}

int main() {
    long long int a,b,c,sum,kake;
    scanf("%lld %lld %lld",&a,&b,&c);
    sum=a+b-c;
    sum=sum*sum;
    kake=a*b*4;
    
    if (c-a-b<0) {
        printf("No");
    }else if (kake<sum) {
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
<?php

$s = trim(fgets(STDIN));
$s = explode(' ', $s);


$W = $s[0];
$H = $s[1];
$x = $s[2];
$y = $s[3];
$r = $s[4];


if ($r <= $x && $r <= $y && $x <= $W - $r && $y <= $H - $r) {
  echo 'Yes' . PHP_EOL;
} else {
  echo 'No' . PHP_EOL;
}

exit;

?>

Measured memory_bytes: 15484
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const ll INF = 1000000000000000001;

int n;
int c[3][3];
int b[3];
int a[3];
int main(void){
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++) cin >> c[i][j];

    for (int i = 0; i <= 100; i++){
        bool flag = true;
        for (int j = 0; j < 3; j++){
            b[j] = c[0][j] - i;
        }
        for (int j = 1; j < 3; j++){
            if (c[j][0] - b[0] == c[j][1] - b[1] && c[j][1] - b[1] == c[j][2] - b[2]) continue;
            flag = false;
        }
        if (flag){
            cout << "Yes" << endl;
            return 0;
        }
        
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

//方針はDFS
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        List<List<Integer>> edge = new ArrayList<>(N+1);
        List<List<Integer>> cost = new ArrayList<>(N+1);
        for(int i=1;i<=N+1;i++){
          edge.add(new ArrayList<>());
          cost.add(new ArrayList<>());
        }

        for(int i=1;i<=N;i++){
          edge.get(i).add(0);
          cost.get(i).add(0);
        }

        for(int i=1;i<=N-1;i++){
          int u = sc.nextInt();
          int v = sc.nextInt();
          int w = sc.nextInt();

            edge.get(u).add(v);
            edge.get(v).add(u);
            cost.get(u).add(w);
            cost.get(v).add(w);

        }


        Deque <Integer> dq = new ArrayDeque<>();
        int status [] = new int[N+1];
        int ans [] = new int[N+1];
        int chakushuzumi = 0;


        for(int i=1;i<=N;i++){
            ans[i]=0;
            status[i]=0;
        }
        dq.push(1);
        status[1]=1;
        while(!dq.isEmpty()){
            int last_in = dq.pollFirst();
            for(int i = 1; i <= edge.get(last_in).size()-1;i++){
                if(status[edge.get(last_in).get(i)] == 0){
                    int u = edge.get(last_in).get(i);
                    int w = cost.get(last_in).get(i);
                    ans[edge.get(last_in).get(i)] = (ans[last_in] + w) % 2;
                    status[edge.get(last_in).get(i)]=1;
                    dq.push(edge.get(last_in).get(i));
                }
            }

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



Measured memory_bytes: 117028
# ABC141E - Who Says a Pun?
def main():
    N = int(input())
    S = input().rstrip()
    ok, ng = 0, N // 2 + 1
    while ng - ok > 1:
        mid = (ok + ng) // 2
        flg, checked = 0, set()
        for i in range(N - 2 * mid + 1):
            checked.add(hash(S[i : i + mid]))
            if hash(S[i + mid : i + 2 * mid]) in checked:
                flg = 1
                break
        if flg:
            ok = mid  # next mid will be longer
        else:
            ng = mid  # next mid will be shorter
    print(ok)  # max length of substrings appeared twice or more


if __name__ == "__main__":
    main()

Measured memory_bytes: 3376
#include<iostream>
#include<cstdio>
using namespace std;
int main(void){
	
	int a,b,c,d,e;
	cin >> a >>b;
	double ans=(double)a/(double)b;
	if(1){
		
	}
	else{
		
	}
//	cout << ans << endl;
//	cout << "" << endl;
	printf("%f\n",ans);
	return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c;
        if(a >= 10){
            c = b;
            System.out.println(c);
        }else{
            c = b + 100*(10 - a);
            System.out.println(c);
        }
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
vector <int> v;
void solve(int n, int k) {
	if(k == 0) return ;
	int parity = (n % 2) * (k % 2);
	if(n % 2 == 0) {
		v.push_back((n + 1) / 2);
		for(int i = 1; i < k; i++) {
			v.push_back(n);
		}
		return ;
	}
	if(parity == 0) {
		int sz = v.size();
		v.push_back((n + 1) / 2);
		solve(n, k - 1);
		if(v.back() == 1) v.pop_back();
		else {
			v[v.size() - 1] -= 1;
			int add = v.size() - sz;
			for(int i = 0; i < k - add; i++) {
				v.push_back(n);
			}
		}
	} else {
		v.push_back((n + 1) / 2);
		solve(n, k - 1);
	}
}

int cnt;
int med;
vector <int> p;
void backtrack(int n, int k) {
	if(p.size() > 0) {
		++cnt;
		if(med == cnt) {
			for(int i : p) {
				printf("%d ", i);	
			}
			printf("\n");
		}
	}
	if(p.size() == k) return ;
	for(int i = 1; i <= n; i++) {
		p.push_back(i);
		backtrack(n, k);
		p.pop_back();
	}
}

int main (int argc, char const* argv[])
{

	int n, k;
	cin >> n >> k;
	solve(n, k);
	for(auto i : v) {
		printf("%d ", i);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 22384
/*F - LCS*/
#include <bits/stdc++.h>
using namespace std;

string cad1;
string cad2;

int n;
int m;

int longestSub(int i, int j);

vector <vector <int> > memo;
vector <vector <short> > aux;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> cad1 >> cad2;

	n = cad1.size();
	m = cad2.size();

	aux = vector <vector <short> >(n + 5, vector <short>(m + 5, 0));
	memo = vector <vector <int> >(n + 5, vector <int>(m + 5, -1));

	longestSub(0, 0);
	
	string ansCad = "";

	int i = 0;
	int j = 0;

	while(i < n and j < m){
		if(aux[i][j] == 1){
			ansCad += cad1[i];
			i++;
			j++;
		}
		else if(aux[i][j] == 2){
			i++;
		}
		else{
			j++;
		}
	}

	cout << ansCad;

	return 0;
}


int longestSub(int i, int j){

	if(i >= n or j >= m)
		return 0;

	if(memo[i][j] != -1){
		return memo[i][j];
	}

	int ans = 0;
	int varAux;

	if(cad1[i] == cad2[j]){
		ans = 1 + longestSub(i + 1, j + 1);
		aux[i][j] = 1;
	}
	else{
		ans = longestSub(i + 1, j);
		varAux = longestSub(i, j + 1);

		if(ans > varAux){
			aux[i][j] = 2;
		}
		else{
			aux[i][j] = 3;
			ans = varAux;
		}
	}

	memo[i][j] = ans;

	return ans;
}

Measured memory_bytes: 53760
n1 = int(input())
n2 = []

m1 = 0
m2 = 0
for i2 in range(n1):
    t1 = int(input())
    n2.append(t1)
    if t1 > m1:
        m2 = m1
        m1 = t1
    elif t1 > m2:
        m2 = t1

for i1 in range(n1):
    if n2[i1] == m1:
        print(m2)
    else:
        print(m1)

Measured memory_bytes: 12532
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String a = sc.next();
    
    if(a.equals("AAA") || a.equals("BBB")){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }   
  }
  
}

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF INT_MAX/2 //(1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

  int N,W;
  cin>>N>>W;
  vector<int>w(N),v(N);
  for(int i=0;i<N;i++)cin>>w[i]>>v[i];

  vector<vector<int> >dp(N+1,vector<int>(1000*N+1,INF));
  dp[0][0]=0;

  for(int i=1;i<=N;i++){
    for(int j=0;j<=1000*N;j++){

      if(j-v[i-1]>=0)dp[i][j]=min(dp[i-1][j-v[i-1]]+w[i-1], dp[i-1][j]);
      else dp[i][j]=dp[i-1][j];

    }
  }

  int Max=0;
  for(int j=0;j<=1000*N;j++){
    if(dp[N][j]<=W)Max=max(Max,j);
    //cout<<dp[N][j]<<" "<<j<<endl;
  }

  cout<<Max<<endl;
  return 0;
}


Measured memory_bytes: 40192
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
    int n, u, v;
    cin >> n >> u >> v;
    u--; v--;
    vvi to(n);
    
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].pb(b);
        to[b].pb(a);
    }
    
    // 高橋くん u からの距離 dist_u
    vi dist_u(n, -1);
    queue<int> q;
    
    q.push(u);
    dist_u[u] = 0;
    
    while(!q.empty()){
        int now = q.front(); q.pop();
        for(auto next : to[now]){
            if(dist_u[next] == -1) {
                dist_u[next] = dist_u[now] + 1;
                q.push(next);
            }
        }
    }    
    
    // 青木くん v からの距離 dist_v
    vi dist_v(n, -1);
    queue<int> emp;
    swap(q, emp);

    q.push(v);
    dist_v[v] = 0;
    
    while(!q.empty()){
        int now = q.front(); q.pop();
        for(auto next : to[now]){
            if(dist_v[next] == -1) {
                dist_v[next] = dist_v[now] + 1;
                q.push(next);
            }
        }
    }    
    
    int mx = -1;
    rep(i, n){
        if(dist_u[i] >= dist_v[i]) continue;
        if(dist_v[i] > mx) mx = dist_v[i];
    }
    
    cout << mx - 1 << endl;
	return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 6656
#include<iostream>
#include<vector>
using namespace std;
#define MOD 1e9+7

int main()
{
    int n;cin>>n;
    vector<int> a(n);
    int i,j;
    for(i=0;i<n;i++)cin>>a.at(i);
    int ans = 1e9;
    int kans;
    for(i=-100;i<=100;i++)
    {
        kans=0;
        for(j=0;j<n;j++)
        {
            kans+=(a.at(j)-i)*(a.at(j)-i);
        }
        if(kans<ans)ans=kans;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define show(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)
#else
#define show(...) 42
#endif


#define f first
#define s second
#define endl "\n"
#define pb push_back
#define  oo 0x3f3f3f3f
#define limit 1000000007
#define two pair<int,int>
#define int long long int
#define mod(x,m) ((x%m+m)%m)
#define all(v) v.begin(),v.end()
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define fori(x,n) for(int i = x; i < n; i++)
#define forj(y,m) for(int j = y; j < m; j++)
#define fork(z,p) for(int k = z; k < p; k++)
#define fastio std::ios::sync_with_stdio(false)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define input_from_file  freopen("input.txt", "r", stdin);

signed main(){
  //input_from_file;
  int n; cin>>n;
  string str; cin>>str;
  if(n%2 != 0) cout<<"No"<<endl, exit(0);
  for(int i=0;i<n/2;i++) if(str[i] != str[n/2+i]) cout<<"No"<<endl, exit(0);
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 888
import fractions
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    def main():
        N, M = map(int, input().split())
        S = str(input())
        T = str(input())

        lcm = N * M // fractions.gcd(N, M)
        NN = lcm // N
        MM = lcm // M

        lcm2 = NN * MM // fractions.gcd(NN, MM)
        i = 0
        ans = lcm
        while True:
            if lcm2 * i // NN < N and lcm2 * i // MM < M:
                if S[lcm2 * i // NN] != T[lcm2 * i // MM]:
                    ans = -1
                i += 1
            else:
                return ans

    print(main())


resolve()

Measured memory_bytes: 65644
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define VMIN (100009)

using namespace std;

int main(){

	long long N, M;

	vector<pair<long long, long long>> m;

	cin >> N >> M;

	for(long long i = 0; i < M ; i++){
		long long a, b;
		cin >> a >> b;
		if(a > b) swap(a, b);
		m.push_back(make_pair(a, b));
	}

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

	vector<pair<long long, long long>> tm;
	long long ans = 0, vi = 0, vmin = VMIN;
	for(long long i = 1; i <= N; i++){
		do {
			if( i != m[vi].first ) break;
			tm.push_back(m[vi]);
			vmin = min(vmin, m[vi].second);
			vi++;
		} while(1);

		if( i == vmin -1 ) {
			ans++;
			vmin = VMIN;
			tm.clear();
		}
	}

	if(tm.size() > 0) ans++;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3312
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>
using namespace std;



int main(){

	int n;
	long long l[87];
	int d;
	cin>>n;
	l[0]=2;
	l[1]=1;
	for(int i=2;i<n+1; i++){
		l[i]=l[i-1]+l[i-2];
	}
	cout<<l[n]<<endl;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
A = list(map(int, input().split()))
t=0
for i in range(N-1):
    for j in range(i+1,N):
        if A[i]>A[j]:
            t+=1
A.sort()
T=0
s=A[0]
n=0
for i in range(1,N):
    if A[i]!=s:
        n=i
        s=A[i]
    T+=n
print((t*K+K*(K-1)//2*T)%(10**9+7))

Measured memory_bytes: 41580
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef pair<double,double>par;
int ar[200005];
int main(){
    int n,x;
    scanf("%d%d",&n,&x);
    if(x==1||x==n*2-1)
        puts("No");
    else{
        puts("Yes");
        x--;
        int m=n*2-1;
        for(int i=x,j=n-1,k=0;k<m;k++,i=(i+1)%m,j=(j+1)%m)
            ar[j]=i;
        for(int i=0;i<m;i++)
            printf("%d\n",ar[i]+1);
        }

    return 0;
    }


Measured memory_bytes: 2304
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int a,b,c,x;
  cin >>a>>b>>c>>x;
  int count=0;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        int sum = 500*i+100*j+50*k;
        if(x==sum) count++;
  }
}
}
cout <<count<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  string s;
  cin >> s;
  ll ans = 0, n;
  n = s.length();
  for(int i = 0; i < n; i++) {
    ans += (int)(s[i] - '0');
  }
  if(ans % 9 == 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define float long double
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define LB lower_bound
#define UB upper_bound
#define g(t, n) get<n>(t)
#define fp(x, y) fixed<<setprecision(y)<<x
#define PI 3.141592653589793238462643383279502884
using namespace std;

const int M = (int)2e5+5;
const int mod = (int)1e9+7;

void solve()
{
    int n;
    cin>>n;
    cout<<1-n<<endl;
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        // cout<<"Case #"<<tno<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3644
import numpy as np
import itertools
h,w,k = map(int, input().split())
c = np.array([list(input()) for _ in range(h)])

p = itertools.product([True,False],repeat = h+w)
ans = 0
for i in p:
    c_cut = c[np.ix_(i[:h],i[h:])]
    if np.count_nonzero(c_cut == '#') == k:
        ans += 1
print(ans)

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

using ll = long long;

ll dp[3003][3003][5];
ll item[3003][3003];

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

int main() {
	int R, C, K;
	cin >> R >> C >> K;
	for (int i = 0; i < K; i++) {
		int r, c, v;
		cin >> r >> c >> v;
		item[r - 1][c - 1] = v;
	}

	for (int i = 0; i <= R; i++) {
		for (int j = 0; j <= C; j++) {
			for (int k = 2; k >= 0; k--) {
				chmax(dp[i][j][k + 1], dp[i][j][k] + item[i][j]);
			}
			for (int k = 0; k <= 3; k++) {
				chmax(dp[i + 1][j][0], dp[i][j][k]);
				chmax(dp[i][j + 1][k], dp[i][j][k]);
			}
		}
	}

	
	ll ans = -1;
	for (int i = 0; i <= 3; i++) {
		ans = max(ans, dp[R][C][i]);
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 425944
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include<complex>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;


int main(){
	int a, b;
	cin >> a >> b;
	if (a != 1 && b != 1) {
		if (a > b) {
			cout << "Alice";
		}
		else if(a<b){
			cout << "Bob";
		}
		else {
			cout << "Draw";
		}
	}
	else if(a==1){
		if (b == 1) {
			cout << "Draw";
		}
		else{
			cout << "Alice";
		}
	}
	else {
		cout << "Bob";
	}
	return 0;
}
//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <iostream>
    #include <cmath>
    using namespace std;
     
    int main()
    {
        int h, w;
        cin >> h >> w;
        char a[h][w];
        for(int i = 0; i<h; i++){
            for(int j = 0; j<w; j++){
                cin >> a[i][j];
            }
        }
        
        for(int i = 0; i<h; i++){
            for(int j = 0; j<w; j++){
                if(a[i][j] == '.') continue;
                if(i!=0 && a[i-1][j] == '#') continue;
                if(j!=0 && a[i][j-1] == '#') continue;
                if(i!=h-1 && a[i+1][j] == '#') continue;
                if(j!=w-1 && a[i][j+1] == '#') continue;
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }

Measured memory_bytes: 256
from sys import exit

x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()

p = list(map(int, input().split()))

for i in range(10000000):
  f = True
  if x-i in p:
    f = False
  if f:
    print(x-i)
    exit()
  if x+i in p:
    continue
  print(x+i)
  exit()

Measured memory_bytes: 9184
S = input()
n = len(S)
p = 10**9+7
DP = [[0]*13 for i in range(n+1)]
DP[0][0] = 1
for i in range(1, n+1):
    for j in range(13):
        if S[i-1] == '?':
            DP[i][j] = sum([DP[i-1][(4*(j-k)) % 13] for k in range(10)]) % p
        else:
            k = int(S[i-1])
            DP[i][j] = DP[i-1][(4*(j-k)) % 13]
print(DP[n][5])


Measured memory_bytes: 61916