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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll N=1e5+2;
const ll MOD=1e9+7;
const ll inf=1e18+6;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(20);
    ll n,d,x,ans=0;
    cin>>n>>d>>x;
    ll A[n];
    forn(i,n) cin>>A[i];
    forn(i,n) ans+=(d-1)/A[i];
    cout<<n+ans+x;

}


Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>

int main(void) {
	int X,x,n,i;
	int m[]={100,101,102,103,104,105 };
	scanf("%d",&X);
	x = X % 100;
	n = X / 100;

	if (5 * n < x)
		printf("0\n");
	else
		printf("1\n");
	/*
	for (i = 0; i < 6; i++) {
		if (X%m[i] == 0) {
			printf("1\n");
			return 0;
		}
	}
	while (x > 0) {

	}
	*/
	return 0;
}


Measured memory_bytes: 128
//https://atcoder.jp/contests/abc122/tasks/abc122_a
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;

int main(){
  string a;
  cin >> a;
  if(a=="A")cout<<"T"<<endl;
  if(a=="T")cout<<"A"<<endl;
  if(a=="G")cout<<"C"<<endl;
  if(a=="C")cout<<"G"<<endl;
  return 0;
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int ans=INT_MAX;
    string s,t;
    cin>>s>>t;
    rep(i,s.size()-t.size()+1){
        int a=t.size();
        rep(j,t.size()) if(s[i+j]==t[j]) a--;
        ans=min(ans,a);
    }
    cout<<ans;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/combine.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    cout << n + n * n + n * n * n << endl;
}

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

bool solve(string s, char except)
{
	s.erase(s.find(except), 2);

	for (int i = 0; i < 4; i++)
	{
		if (count(s.begin(), s.end(), s[0]) >= 3)
		{
			s.erase(0, 3);
		}
		else if (count(s.begin(), s.end(), s[0] + 1) > 0 && count(s.begin(), s.end(), s[0] + 2) > 0)
		{
			s.erase(s.find(s[0] + 2), 1);
			s.erase(s.find(s[0] + 1), 1);
			s.erase(0, 1);
		}
	}

	if (s.size() == 0) return true;
	else return false;
}


int main()
{
	string str;
	while (cin >> str)
	{
		bool IsFirst = true;
		
		for (int i = 1; i < 10; i++)
		{
			if (count(str.begin(), str.end(), char(i + '0')) == 4) continue;
			string s = str;
			s.push_back(char(i + '0'));
			sort(s.begin(), s.end());

			for (int j = 1; j < 10; j++)
			{
				if (count(s.begin(), s.end(), char(j + '0')) >= 2)
				{
					if (solve(s, char(j + '0')))
					{
						if (!IsFirst) cout << ' ';
						cout << i;
						IsFirst = false;
						break;
					}
				}
			}
		}

		if (IsFirst) cout << 0;
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define tmp(x) std::cout<<"& "<<(x)<<" &\n"
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define mp make_pair
#define pii pair<int,int>
typedef long long ll;

using namespace std;
const int maxn=2e3+100;
const int inf=-1e9+100;
int n,t;
int a[maxn*3],dp[maxn][maxn],ans,now[maxn],add;
int  tp[maxn],tnow[maxn];
int tmpdp[maxn][maxn];
vector<vector<int>> card;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    rep(i,1,3*n)cin>>a[i];
    if(n==1){cout<<(a[1]==a[2]&&a[2]==a[3]);return 0;}
    rep(i,1,n)rep(j,1,n)dp[i][j]=inf;
    ans=inf;
    rep(i,1,n)now[i]=inf;


    rep(i,1,n){
        vector<int> v;
        if(i==1){
            rep(j,1,5)v.push_back(a[j]);
        }
        else if(i==n)v.push_back(a[3*n]);
        else rep(j,3*i,3*i+2)v.push_back(a[j]);
        card.push_back(v);
    }

    rep(i,1,5){
        rep(j,1,5){
            if(i!=j){
                int pos=-1,val=1;
                rep(k,1,5){
                    if(k==i||k==j)continue;
                    if(pos==-1)pos=a[k];
                    else if(pos!=a[k])val=0;
                }
                dp[a[i]][a[j]]=dp[a[j]][a[i]]=val;
            }
        }
    }

    rep(i,1,n){
        rep(j,i,n){
            now[j]=max({now[j],dp[i][j]});
        }
    }
    rep(i,1,n)ans=max(ans,now[i]);


    rep(i,1,n-2){//
        if(card[i][0]==card[i][1]&&card[i][0]==card[i][2]){++add;continue;}
        rep(j,1,n)tp[j]=dp[j][j],tnow[j]=now[j];
        rep(j,0,2)rep(k,1,n)tmpdp[card[i][j]][k]=tmpdp[k][card[i][j]]=dp[card[i][j]][k];
        int tans=ans;

        rep(j,0,2){
            int c1=card[i][j],c2=-1,c3=-1;
            rep(k,0,2){
                if(j==k)continue;
                c2=card[i][k];
                rep(u,0,2){
                    if(u!=j&&u!=k)c3=card[i][u];
                }

                dp[c1][c2]=dp[c2][c1]=max({dp[c1][c2],dp[c2][c1],ans});
                if(c3>0)dp[c1][c2]=dp[c2][c1]=max(dp[c1][c2],tp[c3]+1);
                tnow[c1]=max(tnow[c1],dp[c1][c2]);
                tnow[c2]=max(tnow[c2],dp[c1][c2]);
                tans=max(tans,dp[c2][c1]);
            }
        }
        rep(j,0,2){
            int c1=card[i][j],cur=-1;
            rep(k,0,2){
                if(j==k)continue;
                if(cur==-1)cur=card[i][k];
                else if(cur!=card[i][k])cur=-1;
            }
            rep(k,1,n){
                
                dp[c1][k]=dp[k][c1]=max({dp[k][c1], dp[c1][k],now[k]});
                if(cur>0)dp[c1][k]=dp[k][c1]=max({dp[c1][k],tmpdp[cur][k]+1});
                dp[c1][k]=max(dp[c1][k],dp[k][c1]);
                tnow[k]=max({tnow[k],dp[c1][k]});
                tnow[c1]=max({tnow[c1],dp[c1][k]});
                tans=max({tans,dp[c1][k]});

            }
        }

        rep(j,1,n){now[j]=max(now[j],tnow[j]);}
        ans=max(ans,tans);
    }
    ans=max(ans,dp[card[n-1][0]][card[n-1][0]]+1);
//    rep(i,1,n)ans=max(ans,now[i]);
    cout<<ans+add;
//    tmp(ans);
//    tmp(add);
    return 0;
}


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

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
#define inf 100007

using namespace std;

int main(){
    int n;
    cin>>n;
    ll a[n];
    pan(i,n) cin>>a[i];
    ll ai=*max_element(a,a+n),aj=INF,mid=ai/2,dif=INF;
    pan(i,n){
        if(abs(a[i]-mid)<dif && ai>a[i]) aj=a[i],dif=abs(a[i]-mid);
    }
    cout<<ai<<" "<<aj;
}

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

int main() {
    string N;
    cin >> N;
    for (int i=0; i<int(N.size()); i++) {
        if (N.at(i)=='9') {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 256
s = input()
former = s[:2]
latter = s[2:]

# print(former)
# print(latter)

def isYear(s):
    num = int(s)
    # if 0 < num:
    #     return True
    # else:
    #     return False
    return True

def isMonth(s):
    num = int(s)
    if 0 < num < 13:
        return True
    else:
        return False

if (isYear(former) and isMonth(former) and isYear(latter) and isMonth(latter)):
    print('AMBIGUOUS')
elif (isYear(former) and isMonth(latter)):
    print('YYMM')
elif (isYear(latter) and isMonth(former)):
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <stack>

using namespace std;

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

int main() {
	int m;
	cin >> m;
	vector<string> c(m);
	vector<int> l(m), r(m);
	map<string, int> p;
	p["+"] = -1;
	p["-"] = -1;
	p["*"] = -1;
	p["/"] = -1;
	rep(i, m) {
		cin >> c[i] >> l[i] >> r[i];
		p[c[i]] = i;
	}
	vector<vector<int>> d(m);
	rep(i, m) {
		for (int j = l[i]; j <= r[i]; j++) {
			d[i].push_back(j);
		}
	}
	int n;
	cin >> n;
	vector<int> v;
	stack<vector<int>> s;
	rep(k, n) {
		string t;
		cin >> t;
		if (p.count(t)) {
			if (p[t] == -1) {
				auto b = s.top();
				s.pop();
				auto a = s.top();
				s.pop();
				set<int> se;
				each(i, b)each(j, a) {
					if (t == "+") {
						se.insert((j + i) % 256);
					}
					if (t == "-") {
						se.insert((j - i + 256) % 256);
					}
					if (t == "*") {
						se.insert((j * i) % 256);
					}
					if (t == "/") {
						if (i == 0) {
							cout << "error" << endl;
							return 0;
						}
						se.insert((j / i) % 256);
					}
				}
				vector<int> v;
				each(i, se) {
					v.push_back(i);
				}
				s.push(v);
			}
			else {
				s.push(d[p[t]]);
			}
		}
		else {
			s.push(vector<int>(1, atoi(t.c_str())));
		}
	}
	cout << "correct" << endl;

	return 0;
}

Measured memory_bytes: 3204
#include <iostream>
using namespace std;
int main(void){
    int i,j,a,b;
    cin>>a;
    string s;
    cin>>s;
    int frag1=0;
    int frag2=0;
    int white = 0;
    int black = 0;
    for(i=0;i<a;i++){
        if(s[i]=='#')
        black++;
        else
        white++;
    }
    int rewhite=0;
    int reblack=0;
    int k = white;
    for(i=0;i<a;i++){
        if(s[i]=='#'){
        reblack++;
        black = black-1;
        }
        else{
        rewhite++;
        white = white -1;
        }
        if(k>reblack+white)
        k = reblack+white;
    }
    cout<<k<<endl;
}


Measured memory_bytes: 640
using System;
public class Hello{
    public static void Main(){
        var n = int.Parse(Console.ReadLine());
        var ans = "";
        while(n != 0){
            if(n % -2 != 0){
                ans = "1" + ans;
                n--;
            }else{
                ans = "0" + ans;
            }
            n /= -2;
        }
        Console.WriteLine((ans == "") ? "0" : ans);
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
long long a[1000001];

int main(){
  long long n;
  cin >> n;
  a[0] = 7 % n;
  for(int i = 1; i < n; i++) a[i] = (10 * a[i-1] + 7) % n;
  
  for(int i = 0; i < n; i++){
    if(a[i] == 0){
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 11368
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int N, K, A[100005];
ll DP[105][100005], Sum[105][100005];

int main(){
  cin >> N >> K;
  for (int i = 1; i <= N; i++) cin >> A[i];

  DP[0][0] = 1;
  for (int j = 0; j <= K; j++) Sum[0][j] = 1;

  for (int i = 1; i <= N; i++){
    for (int j = 0; j <= K; j++){
      if (j - A[i] <= 0){
        DP[i][j] = Sum[i - 1][j];
      }else{
        DP[i][j] = Sum[i - 1][j] - Sum[i - 1][j - A[i] - 1];
        DP[i][j] %= nmax;
        if (DP[i][j] < 0) DP[i][j] += nmax;
      }
    }

    Sum[i][0] = DP[i][0];
    for (int j = 1; j <= K; j++){
      Sum[i][j] = DP[i][j] + Sum[i][j - 1];
      Sum[i][j] %= nmax;
    }    
  }
  
  cout << DP[N][K] << endl;

  return 0;
}


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

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll n,m;
    while(cin >> n >> m)
    {
        if(n == 1 && m == 1)
            cout << 1 << '\n';
        else if(n == 1)
            cout << m-2 << '\n';
        else if(m == 1)
            cout << n-2 << '\n';
        else
            cout << (n-2)*(m-2) << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   int table[200][200]={{0}};
   int c,r;
   cin >> r >> c;
   for(int i=0;i<r;i++){
       for(int j=0;j<c;j++){
           cin >> table[i][j];
       }
   }
   for(int i=0;i<r+1;i++){
       int sum=0;
       for(int j=0;j<c;j++){
           sum += table[i][j];
       }
       table[i][c]=sum;
   }
   for(int j=0;j<c+1;j++){
       int num=0;
       for(int i=0;i<r;i++){
           num += table[i][j];
       }
       table[r][j]=num;
   }
   for(int i=0;i<r+1;i++){
       for(int j=0;j<c;j++){
           cout << table[i][j] << " ";
       }
       cout << table[i][c] << endl;
   }
}


Measured memory_bytes: 3244
#include "bits/stdc++.h"
#define all(v) (v).begin(), (v).end()
using namespace std;
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define int long long
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define lll __int128
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}
const int N = 1e6;
int fac[N], inv[N];

int cal(int n, int m)
{
	if (n < 0 || m < 0 || m > n)
		return 0;
	return fac[n] * inv[m] % mod * inv[n - m] % mod;
}
signed main()
{
	set<int> s;
	for(int i=1;i<=3;i++){
		int x;cin>>x;s.insert(x);
	}
	if(s.size()==2)puts("Yes");
	else puts("No");

	getchar();
	getchar();
}

Measured memory_bytes: 256
require 'prime'
M=10**9+7
def pow(x,y,z)
a=1
while y>0
a*=x if y&1==1
x=x*x%z
y/=2
end
a
end
n=gets.to_i
A=gets.split.map &:to_i
tbl=Hash.new(0)
A.each{|a|
a.prime_division.each{|x,y|
tbl[x]=[y,tbl[x]].max
}
}
l=1
tbl.each{|x,y|
l*=x**y
l%=M
}
s=0
A.each{|a|
s+=l*pow(a,M-2,M)
s%=M
}
p s

Measured memory_bytes: 3196
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define output(x) cout<<x<<endl;
typedef long long int ll;



int main()
{
	ll  i, j, k, l, m, sum, flag,ans,W,H;
	sum = 0;
	flag = 0;
	int N[3];
	cin >> W;
	j = 2;
	while (W > 0) {
		N[j] = W % 10;
		W /= 10;
		j--;
	}
	sum = 100 * N[0] + 10 * N[1] + N[2];
	int sum1 = 111 * N[0];
	if (sum <= sum1) {
		ans = sum1;
	}
	else
		ans = sum1 + 111;
	output(ans);

	//ソートしてある配列aの各要素の数を前から数え上げることで新しい配列lenに入れている
	return 0;
}



Measured memory_bytes: 256
#[derive(Debug, Clone, Copy)]
struct Edge {
    cost: i64,
    node: usize,
}

// O(V^3)
fn shortest_path(adjl: &Vec<Vec<Edge>>, start: usize) -> Option<Vec<i64>> {
    let n = adjl.len();
    let mut dist: Vec<i64> = vec![INF; n];
    dist[start] = 0;
    let mut relaxed = false;
    for _ in 0..n {
        relaxed = false;
        for u in 0..n {
            for e in &adjl[u] {
                if dist[e.node] > e.cost + dist[u] && dist[u] != INF {
                    dist[e.node] = e.cost + dist[u];
                    relaxed = true;
                }
            }
        }
    }
    if relaxed {
        None
    } else {
        Some(dist)
    }
}

fn solve() {
    let (v, e, start): (usize, usize, usize) = (read::<usize>(), read::<usize>(), read::<usize>());
    let mut adjl = vec![vec![]; v];
    for _ in 0..e {
        let (s, t, cost): (usize, usize, i64) = (read::<usize>(), read::<usize>(), read::<i64>());
        adjl[s].push(Edge { cost, node: t });
    }
    match shortest_path(&adjl, start) {
        Some(dist) => {
            for d in dist {
                if d == INF {
                    println!("INF");
                } else {
                    println!("{}", d);
                }
            }
        }
        None => println!("NEGATIVE CYCLE"),
    }
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;
const INF: i64 = 100_000_000;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========



Measured memory_bytes: 9084
#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(){
    int n;
    string s;
    cin >> n >> s;
    vector<P> sum(n+1);
    rep(i,n){
        if(s[i] == 'E') sum[i+1].first++;
        else sum[i+1].second++;
        sum[i+1].first += sum[i].first;
        sum[i+1].second += sum[i].second;
    }
    int ans = 1e9;
    rep(i,n){
        int cnt = 0;
        cnt += sum[i].second;
        cnt += sum[n].first - sum[i+1].first;
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6128
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x,y;
    int v[13]={-1,1,3,1,2,1,2,1,1,2,1,2,1};

    while(cin>>x>>y){
        if(v[x]==v[y])
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }

    return 0;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

const int m = 2019;

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

    int ans = 0;
    for (int i = a; i < b + 1; i++)
    {
        if (c % i == 0)
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=1e5+50 ;

int n,m,c[N],fail;

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
#endif
	read(n),read(m); 
	rep(i,1,m){
		int a,b;
		read(a),read(b);
		c[a]^=1,c[b]^=1; 
	}
	rep(i,1,n)fail|=c[i]; 
	puts(fail?"NO":"YES"); 
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<queue>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<cstring>
#define For(i,j,k)	for(ll i=j;i<=k;++i)
#define Dow(i,j,k)	for(ll i=k;i>=j;--i)
#define maxm 10011
#define maxn 511
#define pb push_back
#define ll unsigned long long
using namespace std;
inline ll read()
{
	ll t=0,f=1;char c=getchar();
	while(c<'0'||c>'9')	{c=getchar();}
	while(c<='9'&&c>='0')	t=t*10+c-48,c=getchar();
	return t*f;
}
char s[10];
int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	For(i,1,len-1)	if(s[i]=='A'&&s[i+1]=='C')	{puts("Yes");return 0;}
	puts("No");
}

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

int main() {
  string S;
  cin >> S;

  if (S == "ABC")
    cout << "ARC" << endl;
  else
    cout << "ABC" << endl;
  return 0;
}

Measured memory_bytes: 3580
//I read the news today, oh boy
//About a lucky man who made the grade
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ll((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define roF(i,a,b) for(ll i = ll(a); i >= ll(b); i--)
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const ll N=1e6;

string board[2005];
ll h, w;
vi obsx[2005], obsy[2005];

int main(){
	fastio;
	cin>>h>>w;
	For(i,0,h) cin>>board[i];
	For(i,0,h){
		obsx[i].pb(-1);
		For(j,0,w) if(board[i][j]=='#')
			obsx[i].pb(j);
		obsx[i].pb(w);
	}
	For(j,0,w){
		obsy[j].pb(-1);
		For(i,0,h) if(board[i][j]=='#'){
			obsy[j].pb(i);
		}
		obsy[j].pb(h);
	}
	ll ans = 0;
	For(i,0,h){
		int idx=0;
		For(j,0,w){
			if(board[i][j]!='#'){
				ll lo = 0, hi = sz(obsy[j]);
				while(lo+1<hi){
					ll mid = (lo+hi)>>1;
					if(obsy[j][mid]<= i) lo=mid;
					else hi=mid;
				}
				ll idy=lo;
				ll cur = obsx[i][idx+1]-obsx[i][idx]-1;
				cur += obsy[j][idy+1]-obsy[j][idy]-1;
				cur--;
				ans = max(ans,cur);
			}else idx++;
		}
	}
	cout << ans << endl;
	return 0;
}



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

using namespace std;
using ll = long long;

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

const int mod = 1e9 + 7;

int dp[100005];

int f(int i) {
  if (i < 0) return 0;
  if (dp[i] != -1) return dp[i];
  return dp[i] = (f(i - 1) + f(i - 2)) % mod;
}

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

  rep(i, n + 1) dp[i] = -1;
  rep(i, m) {
    int x;
    cin >> x;
    dp[x] = 0;
  }
  dp[0] = 1;
  f(n);
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 7140
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef pair<bool, int> P;

int W, H;
ll costw[100000 + 10], costh[100000 + 10];
pair<ll, P> sortlist[100000 * 2 + 10];

int main() {
	cin >> W >> H;
	for (int i = 0; i < W; i++) {
		cin >> costw[i];
		sortlist[i] = make_pair(costw[i], P(i, 0));
	}
	for (int i = 0; i < H; i++) {
		cin >> costh[i];
		sortlist[i + W] = make_pair(costh[i], P(i, 1));
	}
	sort(sortlist, sortlist + W + H);

	ll ans = 0;
	int cnth = 0, cntw = 0;
	for (int i = 0; i < H + W; i++) {
		if (sortlist[i].second.second == 0) {
			ans += sortlist[i].first * (H + 1 - cnth);
			cntw++;
		}
		else {
			ans += sortlist[i].first * (W + 1 - cntw);
			cnth++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
 
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
int ComputeSum(int cage[10],int l,int r){
  int res = 0;
  for(int i=l;i<=r;i++){
    res += cage[i];
  }
  return res;
}
int main(){
  int max_lion_num,cage_num,man_num;
  while(~scanf("%d %d %d",&cage_num,&max_lion_num,&man_num)){
    int res = -1;
    int res_cage[10];
    int limit[10][10];
    memset(limit,-1,sizeof(limit));
 
    bool count_mistake = 0;
    for(int i=0;i<man_num;i++){
      int left_idx,right_idx,num;
      scanf("%d %d %d",&left_idx,&right_idx,&num);
      if(limit[left_idx-1][right_idx-1] != -1
	 && limit[left_idx-1][right_idx-1] != num){
	count_mistake = true;
      }
      limit[left_idx-1][right_idx-1] = num;
    }
 
    int total_max = pow((max_lion_num+1),cage_num)+EPS;
    for(int i=total_max;i>=0;i--){
      int bits = i;
      int cage[10];
      int total = 0;
      for(int j=0;j<cage_num;j++){
	int lion_num = bits % (max_lion_num+1);
	bits /= (max_lion_num+1);
	cage[j] = lion_num;
	total += lion_num;
	// printf("%d",lion_num);
	// printf("cage_idx:%d lion_num:%d\n",j,lion_num);
      }
      // printf("\n");
 
      bool isok = true;
      for(int l=0;l<cage_num;l++){
	for(int r=l;r<cage_num;r++){
	  if(limit[l][r] == -1) continue;
	  int sum = ComputeSum(cage,l,r);
	  if(sum != limit[l][r]){
	    isok = false;
	  }
	}
      }
      if(isok){
	// printf("total:%d\n",total);
	if(res <= total){
	  res = total;
	  for(int j=0;j<cage_num;j++){
	    res_cage[j] = cage[j];
	  }
	}
      }
    }
 
    if(res != -1 && !count_mistake){
      printf("%d",res_cage[0]);
      for(int i = 1;i <cage_num;i++){
	printf(" %d",res_cage[i]);
      }
      printf("\n");
    }
    else{
      printf("%d\n",-1);
    }
  }
}

Measured memory_bytes: 1232
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#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 printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin >> N >> M;
    ll A[10];
    ll num[10] = {0,2,5,5,4,5,6,3,7,6};
    rep(i,0,M) cin >> A[i];
    sort(A, A+M, greater<ll>());
    ll dp[10010] = {};
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    ll nxt[10010] = {};

    rep(i,0,M){
        rep(j,0,N+1){
            if(dp[j - num[A[i]]] == -1) continue;
            if(j - num[A[i]] >= 0){
                if(dp[j - num[A[i]]] + 1 > dp[j]){
                    dp[j] = max(dp[j], dp[j - num[A[i]]] + 1);   
                }
            }
        }
    }
    string ans = "";
    ll idx = N;
    // printa(dp, N+1);
    ll cnt = 0;
    while(idx != 0){
        rep(i,0,M){
            if(cnt == dp[N]-1){
                if(idx - num[A[i]] == 0){
                    ans += to_string(A[i]);
                    idx = 0;
                    break;
                }
            }else{
                if(dp[idx - num[A[i]]] == dp[idx] - 1){
                    ans += to_string(A[i]);
                    // print(ans);
                    idx -= num[A[i]];
                    cnt++;
                    break;
                }
            }
        }
    }
    print(ans);


    

}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

ll inf=10000000000000000;
ll max_d=1000000000;
typedef pair<ll, ll> P;

int main()
{
    ll N,M;
    cin >> N >> M;
    vector< vector <ll> > vt(M, vector<ll>(3));
    vector<P> next_place[N];
    vector<ll> place(N), starts;
    

    for(int i=0; i<M; i++){
        cin >> vt[i][0] >> vt[i][1] >> vt[i][2];
        next_place[vt[i][0]-1].push_back(P(vt[i][1]-1, vt[i][2]));
        next_place[vt[i][1]-1].push_back(P(vt[i][0]-1, -vt[i][2]));
        starts.push_back(vt[i][0]-1);
    }

    fill(place.begin(), place.end(), inf);
    queue<ll> que;
    bool flag=true;
    for(int ss=0; ss<starts.size(); ss++){
        if(place[starts[ss]]!=inf) continue;
        que.push(starts[ss]);
        place[starts[ss]]=0;
        while(que.size()>0){
            ll now=que.front(); que.pop();
            for(int i=0; i<next_place[now].size(); i++){
                if(place[next_place[now][i].first]==inf){
                    place[next_place[now][i].first]=place[now]+next_place[now][i].second;
                    que.push(next_place[now][i].first);
                }else{
                    if(place[next_place[now][i].first]!=place[now]+next_place[now][i].second){
                        flag=false;
                        break;
                    }
                }
            }
            if(!flag) break;
        }
        if(!flag) break;
        
    }

    ll mi=inf, MA=-inf;

    for(int i=0; i<N; i++){
        if(place[i]==inf) continue;

        if(mi>place[i]) mi=place[i];
        if(MA<place[i]) MA=place[i];
    }
    if(mi!=inf && MA!=-inf && MA-mi>max_d) flag=false;

    if(flag) cout << "Yes";
    else cout << "No";
    
    return 0;
}


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


int main(){
	string s;
	string yaki = "YAKI";
	cin >> s;
	if (s.size() < 4) cout << "No";
	else {
		for (int i = 0; i < 4; i++){
			if (s[i] != yaki[i]){
				cout << "No";
				return 0;
			}
		}
		cout << "Yes";
	}
	return 0;
	
}

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

int main(){
  int N,Q;
  cin>>N>>Q;
  string s;
  cin>>s;
  vector<char> j(Q);
  vector<char> LR(Q);
  vector<bool> ans1(N,false);
  vector<bool> ans2(N,false);
  for(int i=0;i<Q;i++){
    cin>>j[i]>>LR[i];
  }
  char mL=s[0],mR=s[N-1];
  int lp=0,rp=N-1;
  for(int i=Q-1;i>=0;i--){
    if(LR[i]=='L'){
      if(lp<N&&lp>=0&&j[i]==s[lp]){
        if(lp<N) ans1[lp]=true;
        lp++;
      }
      if(rp<N-1&&rp>=0&&j[i]==s[rp+1]){
        if(rp<N) ans2[rp+1]=false;
        rp++;
      }
    }
    if(LR[i]=='R'){
      if(rp<N&&rp>=0&&j[i]==s[rp]){
        if(rp>-1) ans2[rp]=true;
        rp--;
      }
      if(lp<N&&lp>0&&j[i]==s[lp-1]){
        if(lp>-1) ans1[lp-1]=false;
        lp--;
      }
    }
  }
  int cnt=0;
  for(int i=0;i<N;i++){
    if(ans1[i]||ans2[i])
      cnt++;
  }
  cout<<N-cnt<<endl;
}


Measured memory_bytes: 900
#!/usr/bin/env python3
import sys


def solve(s: str, K: int):

    index_dict = {}
    for i in range(len(s)):
        if index_dict.get(s[i]) == None:
            index_dict[s[i]] = [i]
        else:
            index_dict[s[i]].append(i)

    value_list = sorted(set(list(s)))
    candidate = set()

    for string in value_list:
        index = index_dict[string]
        for i in index:
            tmp_s = ""
            for j in range(i,len(s)):
                if len(tmp_s) > K:
                    break
                tmp_s += s[j]
                candidate.add(tmp_s)
        if len(candidate) >= K:
            break
    candidate = list(candidate)
    candidate.sort()
    print(candidate[K-1])

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    K = int(next(tokens))  # type: int
    solve(s, K)

if __name__ == '__main__':
    main()


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


// 0-origin BIT
template <typename T>
class BIT {
public:
	vector<T> data;
	int n;
	BIT() {}
	BIT(int n_) {
		n = n_;
		data.assign(n, T(0));
	}
	// v[a] += w
	void add(int a, T w) {
		for (int x = a; x < n; x |= x + 1) data[x] += w;
	}
	// sum of v[i] for i in [0, a)
	T sum(int a) {
		T ret = 0;
		for (int x = a - 1; x >= 0; x = (x & (x + 1)) - 1) {
			ret += data[x];
		}
		return ret;
	}
};

int N;
int cost[2002][2002][2];
ll memo[2002][2002];

ll dfs(int nb, int nw) {
	if(nb == N && nw == N) {
		return 0;
	}
	if (memo[nb][nw] != -1) return memo[nb][nw];
	ll ret = 1LL << 60;
	if (nb < N) {
		ret = min(ret, dfs(nb + 1, nw) + cost[nb][nw][0]);
	}
	if (nw < N) {
		ret = min(ret, dfs(nb, nw + 1) + cost[nb][nw][1]);
	}
	memo[nb][nw] = ret;
	return ret;
}


int main() {
	cin >> N;

	vector<int> pos_b(N), pos_w(N);
	for(int i=0;i<2*N;i++) {
		char c;
		int a;
		cin >> c >> a;
		if(c == 'W') {
			pos_w[a - 1] = i;
		}else {
			pos_b[a - 1] = i;
		}
	}

	{
		BIT<int> bit_b(2 * N);
		for (int nb = 0; nb <= N; nb++) {
			BIT<int> bit_w(2 * N);
			for (int nw = 0; nw <= N; nw++) {
				if(nb < N) cost[nb][nw][0] = pos_b[nb] - (bit_b.sum(pos_b[nb]) + bit_w.sum(pos_b[nb]));
				if(nw < N) cost[nb][nw][1] = pos_w[nw] - (bit_b.sum(pos_w[nw]) + bit_w.sum(pos_w[nw]));
				if(nw < N) bit_w.add(pos_w[nw], 1);
			}
			if(nb < N) bit_b.add(pos_b[nb], 1);
		}
	}

	memset(memo, -1, sizeof(memo));
	cout << dfs(0, 0) << endl;

	return 0;
}


Measured memory_bytes: 63104
def gcd(a, b):
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b, r)


A, B, K = list(map(int, input().split()))
gcd_val = gcd(A, B)
for i in range(gcd_val, 0, -1):
    if gcd_val % i == 0:
        K -= 1
        if K == 0:
            print(i)
            exit(0)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long A = sc.nextLong();
    long B = sc.nextLong();
    
    if(N%(A+B)>=A){
      System.out.print((N/(A+B))*A + A);
    }else{
      System.out.print((N/(A+B))*A + N%(A+B));
    }
  }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
constexpr ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

/* 最大公約数 */
ll gcdx(ll a, ll b) {
    return b ? gcdx(b, a % b) : a;
}

/* modとる */
inline ll modu(ll a){
    return(a % mod + mod) % mod;
}

/* modつき二分累乗法 */
ll modpow(ll a, ll b) {
    ll res = 1;
    for (a = modu(a); b; a = modu(a * a) , b >>= 1){
        if (b & 1) res = modu(res * a);
    }
    return res;
}

ll sgn(ll A){
    return (A>0)-(A<0);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    REP(i,N)cin >> A[i] >> B[i];
    map<P,P> ma;
    ll appendix = 0;
    REP(i,N){
        if(sgn(A[i]) * sgn(B[i]) == 0){
            if(A[i] == 0&&B[i] == 0){
                appendix++;
            }else if(A[i] == 0){
                B[i] = 1;
                ma[mp(A[i],B[i])].F++;
            }else{
                A[i] = 1;
                ma[mp(B[i],A[i])].S++;
            }
        }else if(sgn(A[i]) * sgn(B[i]) > 0){
            ll gc = gcdx(abs(A[i]),abs(B[i]));
            A[i] /= gc;
            B[i] /= gc;
            ma[mp(abs(A[i]),abs(B[i]))].F++;
        }else{
            ll gc = gcdx(abs(A[i]),abs(B[i]));
            A[i] /= gc;
            B[i] /= gc;
            ma[mp(abs(B[i]),abs(A[i]))].S++;
        }
    }
    ll ans = 1;
    for(auto itr = ma.begin();itr != ma.end();itr++){
        ll plus = 0;
        if(itr->S.F != 0)plus += modpow(2,itr->S.F);
        if(itr->S.S != 0)plus += modpow(2,itr->S.S);
        if(itr->S.F != 0 && itr->S.S != 0)plus--;
        ans *= modu(plus);
        ans = modu(ans);
    }
    cout << modu(ans + appendix - 1) << "\n";
}

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

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

    int n;
    cin >> n;

    vector<int> A;
    for(int i = 1; i <= 100000; i *= 6){
        A.emplace_back(i);
    }
    for(int i = 9; i <= 100000; i *= 9){
        A.emplace_back(i);
    }
    sort(A.begin(), A.end());

    vector<int> dp(n + 1, 1e9);
    dp[0] = 0;

    int a = A.size();

    for(int i = 0; i < a; i++){
        for(int j = A[i]; j <= n; j++){
            dp[j] = min(dp[j], dp[j - A[i]] + 1); 
            //cout << A[i] << " " << j << " " << dp[j] << endl;
        }
    }
    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner sc=new Scanner(System.in);
        int i,n,card;
        int array[]=new int[52];
        String s;
        for(i=0;i<52;i++){
            array[i]=0;
        }
        n=sc.nextInt();
        for(i=0;i<n;i++){
            s=sc.next();
            card=sc.nextInt();
            switch(s){
            case"S":
                card-=1;
                break;
            case"H":
                card+=12;
                break;
            case"C":
                card+=25;
                break;
            case"D":
                card+=38;
                break;
            default:
                continue;
            }
            array[card]=1;
        }
        for(i=0;i<52;i++){
            if(array[i]==0){
                if(i/13==0){
                    System.out.println("S "+(i%13+1));
                }else if(i/13==1){
                    System.out.println("H "+(i%13+1));
                }else if(i/13==2){
                    System.out.println("C "+(i%13+1));
                }else if(i/13==3){
                    System.out.println("D "+(i%13+1));
                }
            }
        }
        sc.close();
    }
}



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

int main( void )
{
    int x;
    cin >> x;
    if ( x == 3 || x == 5 || x == 7 )
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int N, A; cin >> N >> A;

    string ans = "No";
    if (N % 500 <= A) ans = "Yes";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<queue>
#include<set>
#include<string>
#include <vector>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

using namespace std;

#define pi arctan(1/4)
#define r3 pow(3.0,0.5)

struct Pos{
	double x;
	double y;
};

Pos Sum(Pos p, Pos q){
	Pos r;
	r.x = p.x + q.x;
	r.y = p.y + q.y;
	return r;
}

Pos Sca(double a, Pos p){
	Pos q;
	q.x = a*p.x;
	q.y = a*p.y;
	return q;
}

void print(Pos p){
	printf("%lf %lf\n", p.x, p.y);
}

int Koch(Pos left, Pos right, int n){
	if (n != 0){
		Pos s, t, u;
		s = Sum(Sca(2.0 / 3.0, left), Sca(1.0 / 3.0, right));
		t = Sum(Sca(1.0 / 3.0, left), Sca(2.0 / 3.0, right));
		u.x = Sum(Sca(0.5, left), Sca(0.5, right)).x + Sum(Sca(r3*0.5, s), Sca(-1 * r3*0.5, t)).y;
		u.y = Sum(Sca(0.5, left), Sca(0.5, right)).y + Sum(Sca(-1 * r3 / 2, s), Sca(r3 / 2, t)).x;
		Koch(left, s, n - 1);
		print(s);
		Koch(s, u, n - 1);
		print(u);
		Koch(u, t, n - 1);
		print(t);
		Koch(t, right, n - 1);
	}
	else{
		return 0;
	}
	return 0;
}

int main(){
	int n;
	Pos p1, p2;
	p1.x = 0;
	p1.y = 0;
	p2.x = 100;
	p2.y = 0;
	scanf("%d", &n);
	print(p1);
	Koch(p1, p2, n);
	print(p2);
	
	return 0;
}


Measured memory_bytes: 3212
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , q ;
map < int , int > mp ;
int main ( ){
  int x ;
  scanf("%d",&n);
  for  (int i = 0 ; i  < n; i++ ){
    scanf("%d",&x);
    mp[x]++;
  }
  scanf("%d",&q);
  bool sol = 1 ;
  for  ( int i = 0 ; i  < q;  i++ ){
    scanf("%d",&x);
    if ( mp.count(x)){
       if ( mp[x] == 1 ) mp.erase(x);
       else mp[x]-- ;
    }else {
     sol = 0 ;
    }
  }
  if ( sol ) printf("YES");
  else printf("NO");
return 0 ;
}


Measured memory_bytes: 9600
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int K = 19;
const int KM = 1 << (K - 1);
ll dat[1 << K];
ll laz[1 << K];
ll zero = 2e18;

void eval(int A, int l, int r) {
	if (laz[A] == zero) return;
	if (A * 2 < 1 << K) {
		laz[A * 2] = min(laz[A * 2], laz[A]);
		laz[A * 2 + 1] = min(laz[A * 2 + 1], laz[A]);
	}
	dat[A] = min(dat[A], laz[A]);
	laz[A] = zero;
}

ll update(int L, int R, ll X, int A, int l, int r) {
	eval(A, l, r);
	if (r <= L || R <= l) return dat[A];
	if (L <= l && r <= R) {
		laz[A] = min(laz[A], X);
		return min(dat[A], laz[A]);
	}
	dat[A] = min(update(L, R, X, A * 2, l, (l + r) / 2), update(L, R, X, A * 2 + 1, (l + r) / 2, r));
	return dat[A];
}

void add(int L, int R, ll X) {
	update(L, R, X, 1, 0, KM);
}

ll check(int L, int R, int A, int l, int r) {
	eval(A, l, r);
	if (r <= L || R <= l) return zero;
	if (L <= l && r <= R) return dat[A];
	return min(check(L, R, A * 2, l, (l + r) / 2), check(L, R, A * 2 + 1, (l + r) / 2, r));
}

ll query(int L, int R) {
	return check(L, R, 1, 0, KM);
}

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


	int N, M;
	cin >> N >> M;

	rep(i, 1 << K) {
		dat[i] = zero;
		laz[i] = zero;
	}

	tuple<int, int, int> LRC[100000];
	rep(i, M) {
		int l, r, c;
		cin >> l >> r >> c;
		LRC[i] = tie(l, r, c);
	}
	sort(LRC, LRC + M);

	add(1, 2, 0);
	rep(i, M) {
		ll k = query(get<0>(LRC[i]), get<0>(LRC[i]) + 1) + get<2>(LRC[i]);
		add(1, get<1>(LRC[i]) + 1, k);
	}

	ll kotae = query(N, N + 1);
	if (kotae != zero) co(query(N, N + 1));
	else co(-1);

	Would you please return 0;
}

Measured memory_bytes: 9600
import numpy as np
import sys
imput = sys.stdin.readline
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    h = np.array(h)
    cost = np.empty(n)
    cost[0] = 0
    cost[1] = abs(h[1] - h[0])
    for i in range(2, n):
        j = min(i, k)
        cost[i] = np.min(cost[i-j:i] + np.abs(h[i-j:i] - h[i]))
    print(int(cost[-1]))
main()


Measured memory_bytes: 22916
# https://atcoder.jp/contests/abc106/tasks/abc106_d
# 何も見ずにやり直してみる

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


N, M, Q = read_ints()

# 列車を二次元座標に代入
table = [[0] * N for _ in range(N)]  # 都市はそれぞれ-1扱い
for _ in range(M):
    L, R = read_ints()
    table[L - 1][R - 1] += 1

# 二次元累積和を取る
import numpy as np
table_ = np.array(table)
table = np.zeros((N + 1, N + 1), dtype='int')
table[1:, 1:] = table_.cumsum(axis=0).cumsum(axis=1)
# print(table)

# クエリに答える
for _ in range(Q):
    p, q = read_ints()
    print(table[q, q] - table[p - 1, q] -
          table[q, p - 1] + table[p - 1, p - 1])


Measured memory_bytes: 20276
#include <algorithm>
#include <iostream>
#include <vector>

int n, m, c;

int main() {
    std::cin >> n >> m;
    std::vector<int> fav_foods(m, 0);
    for (int i = 0; i < n; i++) {
        std::cin >> c;
        for (int p = 0; p < c; p++) {
            int t;
            std::cin >> t;
            fav_foods[t-1]++;
        }
    }
    std::cout << std::count(fav_foods.begin(), fav_foods.end(), n) << std::endl;
}


Measured memory_bytes: 256
# N を K進数で表したとき、何桁になるか
n, k = map(int, input().split())


import string
numbers = "0123456789"
alphabets = string.ascii_letters # a-z+A-Zをロード
characters = numbers + alphabets
 
def base_cvt(value, n=2):
    try:
        tmp = int(value)
    except:
        raise ValueError('Invalid value:', value)
 
    if n < 2 or n > len(characters):
        raise ValueError('Invalid n:', value)
 
    result = ''
    tmp = int(value)
    while tmp >= n:
        idx = tmp%n
        result = characters[idx] + result
        tmp = int(tmp / n)
    idx = tmp%n
    result = characters[idx] + result
    return result

print(len(str(base_cvt(n, k))))

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

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    int ans = 1;
    if (s == "FRI") ans = 2;
    if (s == "THU") ans = 3;
    if (s == "WED") ans = 4;
    if (s == "TUE") ans = 5;
    if (s == "MON") ans = 6;
    if (s == "SUN") ans = 7;
    cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{

  int i, j , flag = 0 , count = 0,A[100],swap,N;

  scanf("%d",&N);
  for(i = 0 ; i<N ; i++) scanf("%d",&A[i]);
    
  for(i = 0;i <N; i++)
    {
      for(j = N-1 ; j >i ; j--)
	{
	  
	  if (A[j] < A[j -1]  )
	    {
	      swap = A[j];
	      A[j] = A[j -1];
	      A[j -1] = swap;
	      count++;
	    }
	  
	}

    }
  for(i =0 ; i <N ; i++)
    {
      if(i ==  N-1)
	{
	  printf("%d\n%d\n",A[i],count);
	  break;
	}
      printf("%d " , A[i]);
    }
}



Measured memory_bytes: 2140
#include <string>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string.h>
#include <utility>
#include <queue>
#include <stack>
#include <iomanip>
#include <ctype.h>
#include <map>
#include <set>
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include <sstream>
#include <math.h>
#include <time.h>
#include <iostream>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <tuple>
#include <cmath>
#include <stdio.h>      /* printf, fgets */
#include <stdlib.h>
#include <fstream>

using namespace std;

typedef long long LL;

#define FOR(i,n) for(int i = 0;i < n;i++)
#define MP make_pair
#define PB push_back
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define CLEAR(a) memset(a, 0, sizeof(a))
#define INF 2000000007LL
#define y1 uu1
#define y2 uu2
const double EPS = 1E-12;
const double PI = acos(-1.0);
const LL mod = 1000000007;

using namespace std;

LL x,y;

LL fpow(LL x, LL pw) {
  if (pw == 0) return 1;
  LL base = fpow(x, pw/2);
  if (pw & 1) {
    return (x*((base*base)%mod)%mod);
  } else {
    return (base*base)%mod;
  }
}

LL inv(LL x) {
  return fpow(x, mod - 2);
}

int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin >> x >> y;
  if (x > y) swap(x, y);

  if (((x + y) % 3 != 0) || y > 2*x) {
    cout << 0 << endl;
    return 0;
  }

  int nsteps = (x + y) / 3;
  x -= nsteps;
  y -= nsteps;

  LL ans = 1;

  for (LL i = 1; i <= x; i++) {
    ans *= inv(i);
    ans %= mod;
    ans *= (y + i);
    ans %= mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256