akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int D()
{
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
const int N=2e5+9;

int arr[N],in[N];
int main(){

   int  n =D();
   ll sum=0;
   for(int i=1; i<=n;i++)
    {
        arr[i]=D();

      sum+=arr[i];
    }
    int q=D();
    for(int i =1 ;i<=q;i++)
    {
        int x=D();
        int y=D();
        printf("%d\n",sum-arr[x]+y);
    }


    }

/**
bool ok(int val){
  int cntm=0,cntp=0;
  for(int i=0;i<n-val;i++)
  {
      cntm=0;cntp=0;
      for(int j=i;j<val;j++)
      {
      (arr[j]==1)?cntp++:cntm++;
      }
      if(cntp==cntm)
        break;
  }
  return cntp==cntm;
}
int binarySearch(){
  int low = 0, med, hi =n;
  while(low<hi){
    med = (low+hi+1)>>1;
    cout<<med<<" "<<hi<<" "<<low<<endl;
    if(ok(med))  low = med;
    else  hi = med-1;
  }
  return low;
}*/



/**
  int power1(int b, int p){               //O(p)
    if(!p)  return 1;
    return b*power1(b, p-1);
  }
  int power2(int b, int p){               //O(Log(p))
    if(!p)  return 1;
    int ret = power2(b, p/2);
    return (p&1 ? ret*ret*b : ret*ret);
  }
   int mul(int a, int b, int m){
      return (a%m * b%m) % m;
  }

*/


/**
void seive()
{
    bitset<N>iscomp;
    iscomp[0]=iscomp[1]=1;
    for(long long i=2; i<=N; ++i)
    {
        if(!iscomp[i])
        {
            a.push_back(i);
            for(long long j=i*i; j<=N; j+=i)
                iscomp[j]=1;
        }
    }
}
3
abc
abc
*/

    /**


    */


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int a,b,x;
  cin>>a>>b>>x;
  if(a%x==0 && b%x==0){
    cout<<(b/x)-(a/x)+1<<endl;
  }else if(a%x==0 && b%x!=0){
    cout<<(b/x)-(a/x)+1<<endl;
  }else if(a%x!=0 && b%x==0){
    cout<<(b/x)-(a/x)<<endl;
  }else if(a%x!=0 && b%x!=0){
    cout<<(b/x)-(a/x)<<endl;
  }
  
}
///////////////////////////



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int a;
int main(){
	a=read();
	printf("%d\n",a+a*a+a*a*a);
	return 0;
}

Measured memory_bytes: 3688
#include <stdio.h>

int main(void)
{
    int a,b,c;
    int i;
    int count=0;

    scanf("%d %d %d",&a,&b,&c);

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

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

    return 0;
}


Measured memory_bytes: 2716
a, b, c, x, y = map(int, input().split())

cost1 = a * x + b * y
cost2 = c * max(x, y) * 2
if x < y:
    cost3 = c * x * 2 + b * (y - x)
else:
    cost3 = c * y * 2 + a * (x - y)
print(min(cost1, cost2, cost3))

Measured memory_bytes: 9060
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	ll lis[99999];
	ll n;
	bool dp[101][101][101];

	ll f(ll i, ll j, ll k) {
		return (i*i + j*j + k*k + i*j + j*k + i*k);
	}

	
	int main()
	{
		std::ios::sync_with_stdio(false);
		
		cin>>n;
		memset(lis,0,sizeof(lis));
		memset(dp,false,sizeof(dp));
		for(ll i=1; i<=sqrt(n); i++) {
			for(ll j=1; j<=sqrt(n); j++) {
				for(ll k=1; k<=sqrt(n); k++) {
					ll num = f(i,j,k);
					if(dp[i][j][k] == false) {
						lis[num] = lis[num] + 1;
						dp[i][j][k] = true;	
					}
						
				}
			}
		}

		for(ll i=1; i<=n; i++) {
			
		cout<<lis[i]<<endl;	
			
		}
	
		return 0;
	}


Measured memory_bytes: 5472
#include <cstdio>

int main()
{
	int n;
	scanf("%d", &n);
	if(n==1)
		puts("Hello World");
	else
	{
		int a,b;
		scanf("%d %d", &a,&b);
		printf("%d\n", a+b);
	}
	
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()

const int mod = 1000000007;


typedef vector<int> vec;
typedef vector<vec> mat;

//A*Bの計算
mat mul(mat&A, mat&B){
    mat C(A.size(),vec(B[0].size()));
    for(int i=0;i<A.size();i++){
        for(int k=0;k<B.size();k++){
            for(int j=0;j<B[0].size();j++){
                C[i][j]=(C[i][j]+A[i][k]*B[k][j])%mod;
            }
        }
    }
    return C;
}

//A^nの計算
mat pow(mat A,long long n){
    mat B(A.size(),vec(A.size()));
    for(int i=0;i<A.size();i++){
        B[i][i]=1;
    }
    while(n>0){
        if(n%2==1)B=mul(B,A);
        A=mul(A,A);
        n/=2;
    }
    return B;
}

template <int mod>
struct ModInt{
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p){
        if ((x += p.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p){
        if ((x += mod - p.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p){
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p){
        *this *= p.inverse();
        return *this;
    }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    ModInt pow(int e){
        long long a = 1, p = x;
        while (e > 0){
            if (e % 2 == 0){
                p = (p * p) % mod;
                e /= 2;
            }
            else{
                a = (a * p) % mod;
                e--;
            }
        }
        return ModInt(a);
    }

    friend ostream &operator<<(ostream &os, const ModInt<mod> &p){
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a){
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

using modint = ModInt<mod>;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    mat a(n,vec(n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)cin>>a[i][j];
    }
    mat x=pow(a,k);
    modint res=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            res+=x[i][j];
        }
        
    }
    cout<<res<<endl;
}

Measured memory_bytes: 384
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let xy: Vec<u32> = read_vec();
    let mut ans: u32 = 0;
    let x = xy[0];
    let y = xy[1];
    if x == 1 {
        ans += 300000;
    } else if x == 2 {
        ans += 200000;
    } else if x == 3 {
        ans += 100000;
    }
    if y == 1 {
        ans += 300000;
    } else if y == 2 {
        ans += 200000;
    } else if y == 3 {
        ans += 100000;
    }
    if x == 1 && y == 1 {
        ans += 400000;
    }
    println!("{}", ans);
}


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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, k; cin >> n >> k;
    vector<int> a(n,0), b(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int iter = 0; iter < min(500,k); iter++) {
        vector<int> pfx(n+1,0);
        for (int i = 0; i < n; i++) {
            pfx[max(0,i-a[i])]++;
            pfx[min(n,i+a[i]+1)]--;
        }
        for (int i = 1; i <= n; i++) {
            pfx[i] += pfx[i-1];
        }
        a = pfx;
    }
    for (int i = 0; i < n; i++) {
        cout << a[i] << ' ';
    }
    cout << '\n';
}


Measured memory_bytes: 6340
using System;   //ここと
class Program   //ここから
    {
        static void Main(string[] args)
        {
            // 整数の入力
            int a = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int b = int.Parse(input[0]);
            int c = int.Parse(input[1]);


            int waru_big = c / a;

            if (b > (a * waru_big))
            {
                Console.WriteLine("NG");
            }else
            {
                Console.WriteLine("OK");
            }
            
            //出力
            //Console.WriteLine((a + b + c) + " " + s);


            //string[] iStop = Console.ReadLine().Split(' ');    //停止用
        }
    }   //ここまで

Measured memory_bytes: 27536
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(){
    ios::sync_with_stdio(false);
    string s; cin >> s;
    ll k; cin >> k;
    if(s.size()==1) cout << s[0] << endl;
    else{
        if(s[0]!='1') cout << s[0] << endl;
        else{
            int idx=0;
            rep(i,s.size()){
                if(s[i]=='1'){
                    idx++;
                    continue;
                }
                else break;
            }
            if(idx>=k) cout << 1 << endl;
            else cout << s[idx] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std ;

int main()
{
	int a ,b ;
	while( true )
	{
		cin >> a ;
		char c ;
		cin >> c >> b ;
		if( c == '?' )
			return 0 ;
		else if( c == '+' )
			cout << a + b << endl ;
		else if( c == '-' )
			cout << a - b << endl ;
		else if( c == '*' )
			cout << a * b << endl ;
		else if( c == '/' )
			cout << a / b << endl ;
	}
}

Measured memory_bytes: 3092
#include <iostream>
#include <cstring>

using namespace std;

char s[4];
int c=0, cmax=0;

int main()
{
   cin>>s;
   for (int i=0; i<3; i++)
   if (s[i]=='R') {c++; if (c>cmax) cmax=c;}
   else c=0;
   
   cout<<cmax;
   
   return 0;
}

Measured memory_bytes: 3640
a, b, k = map(int, input().split())
l = []
for i in range(a, a+k):
    if i <= b:
        l.append(i)
for i in range(b-k+1, b+1):
    if a <= i:
        l.append(i)
l = set(l)
for i in sorted(l):
    print(i)

Measured memory_bytes: 38256
#include "bits/stdc++.h"
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
int n,m,q;
int v[100010] = {0};
int d[100010] = {0};
int c[100010] = {0};
vector<int> G[100010];
int dp[100010][11] = {0};
void paint(int V,int D,int C){
    if(dp[V][D] || D < 0)return;
    dp[V][D] = C;
    for(auto x:G[V]){
        paint(x,D-1,C);
    }
    paint(V,D-1,C);
    return;
}
signed main(){

    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        G[a-1].pb(b-1);
        G[b-1].pb(a-1);
    }
    cin >> q;
    rep(i,q){
        cin >> v[i] >> d[i] >> c[i];
    }
    for(int i = q-1;i >= 0;i--){
        paint(v[i]-1,d[i],c[i]);
        // rep(i,n)cerr << color[i] << " ";
        // cerr << endl;
    }
    rep(i,n)cout << dp[i][0] << endl;

    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d
// rm -r -f test;oj dl http://agc012.contest.atcoder.jp/tasks/agc012_b

Measured memory_bytes: 17780
#include<bits/stdc++.h>
using namespace std;
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forp(i,a,b) for (int i=a; i<b; i++)
#define forn(i,a,b) for (int i=a; i>b; i--)
#define mod 1000000007
#define PI 3.14159265
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

long long int fact(long long int n){
	if(n==0 || n==1)
	return 1;
	else
	return (n*fact(n-1)%mod)%mod;
}

int prime(long long int n){
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0){
			return 0;
		}
	}
	return 1;
}

long long int gcd(long long int a,long long int b){
	if(a==0)
	return b;
	else
	return gcd(b%a,a);
}

long long int lcm(long long a,long long b){
	return (a*b)/gcd(a,b);
}

int check_palin(string s){
	string str=s;
	reverse(str.begin(),str.end());
	if(str==s)
	return 1;
	else
	return 0;
}

int main(){
	fast_io
	
int n,m,k,ans=1,c=0;
cin>>n>>k;
int a[10]={0};
forp(i,0,k){
	cin>>m;
	a[m]++;
}
while(1){
	m=n;
	c=0;
	while(m){
		if(a[m%10]==1){
			c=1;
			break;
		}
		m/=10;
	}
	if(c)
	n++;
	else
	{
		cout<<n;
		break;
	}
}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		double r = scan.nextDouble();
		double g = scan.nextDouble();
		double ans =(g-r/2)*2;
		if(ans - (int)ans!=0) {
			System.out.println(ans);
		}else {
			System.out.println((int)ans);
		}
	}

}



Measured memory_bytes: 23760
[n,m]= list(map(int,input().split(" ")))
h = list(map(int,input().split(" ")))
lst = [1 for i in range (n)]
for i in range (m):
    [a,b] = list(map(int,input().split(" ")))
    if h[a-1]>h[b-1]:
        lst[b-1]=0
    elif h[a-1]<h[b-1]:
        lst[a-1]=0
    else:
        lst[a-1]=0
        lst[b-1]=0
    
print(lst.count(1))

Measured memory_bytes: 20144
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vvvi=vector<vvi>;


void min_u(int&m, int v)
{
	if(m>v) m=v;
}


int calc(vvi&t, int k)
{
	int h=t.size();
	int w=t[0].size();
	int x=0;
	int ret=0;

if(0)
{
	printf("\n---calc---\n");
	for(auto&mt:t)
	{
		for(int mmt:mt) printf("%d ", mmt);
		printf("\n");
	}
}

	vi s(h);

	for(;;)
	{
		int l_min=w-x;
		for(int y=0;y<h;y++)
		{
			auto its=t[y].begin()+x;
			auto ite=upper_bound(its, t[y].end(), s[y]+k);
			int l=ite-its;
			min_u(l_min, l);
		}
		x+=l_min;
		if(x>=w) break;
		if(l_min<1) return 999999999;
		for(int y=0;y<h;y++)
		{
			s[y]=t[y][x-1];
		}
		ret++;
	}
	return ret;
}


void hoge(int&ans, vvi&t, vvvi&m, int y, int h, int k, int at)
{
	if(y==h)
	{
		min_u(ans, calc(t, k)+at);
		return;
	}

	for(int d=1;y+d<=h;d++)
	{
		t.push_back(m[y][d]);
		hoge(ans, t, m, y+d, h, k, at+1);
		t.pop_back();
	}
}


void m_dump(vvvi&m)
{
	int h=m.size();
	int w=m[0][0].size();

	for(int y=0;y<h;y++)
	{
		auto&my=m[y];
		for(int d=1;d<my.size();d++)
		{
			auto&myd=my[d];
			printf("[y=%d d=%d]\n", y, d);
			for(int x=0;x<w;x++) printf("%d ", myd[x]);
			printf("\n");
		}
	}
	printf("\n");
}


int main(void)
{
	int h, w, k;

	while(scanf("%d%d%d", &h, &w, &k)==3)
	{
		vvi s(h);

		for(auto&ms:s) ms.resize(w);
		for(int y=0;y<h;y++)
		{
			for(int x=0;x<w;x++) scanf("%1d", &s[y][x]);
		}


		vvi cs(h);

		for(auto&ms:cs) ms.resize(w);
		for(int y=0;y<h;y++)
		{
			cs[y][0]=s[y][0];
			for(int x=1;x<w;x++) cs[y][x]=cs[y][x-1]+s[y][x];
		}

		vvvi m(h);
		for(int y=0;y<h;y++)
		{
			m[y].resize(h-y+1);
			for(auto&mmy:m[y]) mmy.assign(w, 0);

			auto&m1=m[y][1];
			m1[0]=s[y][0];
			for(int x=1;x<w;x++) m1[x]=m1[x-1]+s[y][x];
		}

		for(int d=2;d<=h;d++)
		{
			for(int y=0;y+d<=h;y++)
			{
				for(int x=0;x<w;x++)
				{
					m[y][d][x]=m[y][d-1][x]+m[y+d-1][1][x];
				}
			}
		}

//		m_dump(m);

		vvi t;
		int ans=h+w;
		hoge(ans, t, m, 0, h, k, -1);
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
ll memo[3001][3001];
ll h,w;
string s,t;
ll findans(ll i,ll j)
{
    if(i==s.length()||j==t.length())
    {
        return 0;
    }
    /*if(i==n-1)
    {
       
        if(sum+w[i]<=we)
        {
            return v[i];
        }
        else
        {
            return 0;
        }
    }*/
   if(memo[i][j]!=-1)
    {
        return memo[i][j];
    }
    ll ans1=0;
    ll ans2=0;
    ll ans3=0;
    if(s[i]==t[j])
    {
        //cout<<i<<" "<<j<<'\n';
        ans1=1+findans(i+1,j+1);
    }
     ans2=findans(i+1,j);
     ans3=findans(i,j+1); 
    return memo[i][j]=max(ans1,max(ans3,ans2));//memo[i][sum]=
}
int main(){
    // Your code here!
    
    cin>>h>>w;
    vector<string>v;
    for(ll i=0;i<h;i++)
    {
        string s;
        cin>>s;
        v.push_back(s);
    }
   /* for(ll i=0;i<h;i++)
    {
        cout<<v[i]<<'\n';
    }*/
    ll dp[h][w];
    dp[0][0]=1;
    for(ll i=1;i<h;i++)
    {
        if(v[i][0]=='#')
        {
            dp[i][0]=0;
        }
        else
        {
            dp[i][0]=dp[i-1][0];
        }
    }
    for(ll j=1;j<w;j++)
    {
        if(v[0][j]=='#')
        {
            dp[0][j]=0;
        }
        else
        {
            dp[0][j]=dp[0][j-1];
        }
    }
    for(ll i=1;i<h;i++)
    {
        for(ll j=1;j<w;j++)
        {
            if(v[i][j]=='#')
            {
                dp[i][j]=0;
            }
            else
            {
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }
        }
    }
   /* for(ll i=0;i<h;i++)
    {
        for(ll j=0;j<w;j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<'\n';
    }*/
    cout<<dp[h-1][w-1]%mod;
    return 0;
}


Measured memory_bytes: 12376
def solve_coin_change(coins, value):
    table = [None for x in range(value + 1)]
    table[0] = []
    for i in range(1, value + 1):
        for coin in coins:
            if coin > i: 
                continue
            elif not table[i] or len(table[i - coin]) + 1 < len(table[i]):
                if table[i - coin] != None:
                    table[i] = table[i - coin][:]
                    table[i].append(coin)

    if table[-1] != None:
        return len(table[-1])
    else:
        return -1      

# Driver program to test above function
coins1 = [1]
coins6 = [6]
coins9 = [9]

maximum = 100000
i = 1
while True:
    new = coins6[i-1] * coins6[0]
    if new <= maximum:
        coins6.append(new)
        i += 1
    else:
        break
i = 1
while True:
    new = coins9[i-1] * coins9[0]
    if new <= maximum:
        coins9.append(new)
        i += 1
    else:
        break

n = int(input())
print(solve_coin_change(coins1 + coins6 + coins9, n))

Measured memory_bytes: 23284
import sys
readline = sys.stdin.readline

# ジャンプa : (i + 1, j + 2)
# ジャンプb : (i + 2, j + 1)

X,Y = map(int,readline().split())
DIV = 10 ** 9 + 7

from functools import reduce
def nCr(n,r,DIV):
  if r < n - r:
    r = n - r
  if r == 0:
    return 1
  f = lambda x,y:x*y%DIV
  X = reduce(f,range(n-r+1, n+1))
  Y = reduce(f,range(1, r+1))
  return X * pow(Y, DIV - 2, DIV) % DIV

# ジャンプaの回数は0～X回。これを全探索する
for a in range(X + 1):
  b = Y - a * 2
  if b < 0:
    continue
  if a + b * 2 == X and a * 2 + b == Y:
    print(nCr(a + b, a, DIV))
    break
else:
  print(0)


Measured memory_bytes: 9544
# ABC 160 D
# https://atcoder.jp/contests/abc160/tasks/abc160_d

n, x, y = gets.chomp.split(/ /).map(&:to_i)
array = 1.upto(n).map { |i| i.times.map { Float::INFINITY } }

for i in 1..(n - 1) do
  for j in (i + 1)..n do
    array[j - 1][i - 1] = [
      j - i,
      (x - i).abs + 1 + (y - j).abs,
      (y - i).abs + 1 + (x - j).abs
    ].min
  end
end

a_flatten = array.flatten
h = a_flatten.group_by { |i| i }

1.upto(n - 1) do |i|
  v = h[i]
  if v
    puts v.length
  else
    puts 0
  end
end


Measured memory_bytes: 57980
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)
 
int main() {

long N,M;
long K;
long Bread;
long Asum=0,Bsum=0;
long Answer=0;
long rest;
cin>>N>>M>>K;
vector<long> A(N);
vector<long> B(M);
vector<long> AS(N);
vector<long> BS(M);
for(int i=0;i<N;i++){
cin>>A.at(i);
Asum+=A.at(i);
AS.at(i)=Asum;
}
sort(AS.begin(),AS.end());
for(int i=0;i<M;i++){
cin>>B.at(i);
Bsum+=B.at(i);
BS.at(i)=Bsum;
}
sort(BS.begin(),BS.end());
vector<long>::iterator position;
for(int i=0;i<N;i++){
    if(AS.at(i)<K){
        rest=K-AS.at(i);
        position=upper_bound(BS.begin(),BS.end(),rest);
         Bread=distance(BS.begin(),position);                      
          if(Answer<Bread+i+1){
            Answer=Bread+i+1;
        }


    }else if(AS.at(i)==K){
        if(Answer<i+1){
            Answer=i+1;
        }
    }
}
position=upper_bound(BS.begin(),BS.end(),K);
Bread=distance(BS.begin(),position);     
if(Answer<Bread){
    Answer=Bread;
}

cout<<Answer<<endl;



}

Measured memory_bytes: 9592
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;
	cin>>s>>t;
	map<char,char>mp1,mp2;
	for(int i=0; i<s.size(); i++){
		mp1[s[i]]=t[i];
	}
	for(int i=0; i<s.size(); i++){
		mp2[t[i]]=s[i];
	}
	bool flag =true;
	for(int i=0; i<s.size(); i++){
		if(mp1[s[i]]!=t[i]){flag=false;}
		if(mp2[t[i]]!=s[i]){flag=false;}
	}
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

#define int long long

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

int N, K;
int D[9];

signed main() {
    cin >> N >> K;
    for (int i = 0; i < K; i++) {
        cin >> D[i];
    }
    while (true) {
        string s = to_string(N);
        for (int i = 0; i < s.length(); i++) {
            for (int j = 0; j < K; j++) {
                if (s[i] - '0' == D[j]) {
                    goto check;
                }
            }
        }
        cout << N << endl;
        return 0;
check:  N++;
    }
    return 0;
}


Measured memory_bytes: 256
S = input()
T = input()
dp = [[0 for i in range(len(T)+1)] for j in range(len(S)+1)]
for i in range(1,len(S)+1):
    for j in range(1,len(T)+1):
        if S[i-1] == T[j-1]:
            dp[i][j] = 1 + dp[i-1][j-1]
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1]) 

length = dp[len(S)][len(T)]
LCS = [0]*length
i = len(S)
j = len(T)
while i > 0 and j > 0: 
    if S[i-1] == T[j-1]: 
        LCS[length-1] = S[i-1]
        i-=1
        j-=1
        length-=1
    elif dp[i-1][j] > dp[i][j-1]: 
        i-=1
    else: 
        j-=1
print("".join(LCS))

Measured memory_bytes: 120000
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int a[n],i;
    int av=0,cost1=0,cost2=0;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        av += a[i];
    }
    av /= n;
    int av2= av+1; 
    for(i=0;i<n;i++){
       cost1 += (a[i]-av)*(a[i]-av);
       cost2 += (a[i]-av2)*(a[i]-av2);
        
    }
    printf("%d",(cost1<cost2?cost1:cost2));
    return 0;
}

Measured memory_bytes: 1720
import itertools
n=int(input())
plist=list(input().split())
qlist=list(input().split())
p=str("".join(plist))
q=str("".join(qlist))

numlist=[str(i+1) for i in range(n)]
jun=[]
for v in itertools.permutations(numlist,n):
	jun.append("".join(v))

print(abs(jun.index(p)-jun.index(q)))



Measured memory_bytes: 6040
/* long long or int & the MAX_INT or MIN_INT */
/* the size of a[] & inline */
/* xx 396 */

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

const int MAX_N=1e5+10;

int cnt[MAX_N],N;
vector <int> G[MAX_N];
int First;
vector <int> Main;

inline void dfs(int at,int p){
	cnt[at]=1; Main.push_back(at);
	if(at==N-1) First=Main[(Main.size()+1)/2];
	for(int i=0;i<G[at].size();i++){
		int to=G[at][i];
		if(to!=p){
			dfs(to,at);
			cnt[at]+=cnt[to];
		}
	}
	Main.resize(Main.size()-1);
}

signed main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>N;
	for(int i=0;i<N-1;i++){
		int a,b; cin>>a>>b; a--; b--;
		G[a].push_back(b); G[b].push_back(a);
	}
	dfs(0,-1);
	bool win=cnt[First]*2<N;
	if(win) cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
	return 0;
}

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

map<int, int> a;
int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a) cout << k;
    else if (k <= a + b)  cout << a;
    else  cout << 2 * a + b - k;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;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;
ll mod=1e9+7;
ll inv(ll a){
    ll n=mod-2,ans=1;
    while(n>0){
        if(n&1) ans=ans*a%mod;
        n=n/2;
        a=a*a%mod;
    }
    return ans;
}
int main(){
    ll n,x[200001],ans=0,a=0,b=1,mod=1e9+7;
    cin>>n;
    rep(i,n) cin>>x[i];
    rep(i,n-1) (b*=i+1)%=mod;
    rep(i,n-1) a+=b*inv(i+1)%mod,(ans+=(x[i+1]-x[i])*a)%=mod;
    cout<<ans<<"\n";
}

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

int main(){
	int a, b, c, d;
	int start, end;
	cin >> a >> b >> c >> d;
	start = max(a, c);
	end = min(b, d);
	if(start < end) cout << end - start;
	else cout << 0;
}

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

using namespace std;

int main()
{
  int H, W;
  vector< tuple< int, int, int > > data;
  for(int i = 1; i <= 150; i++) {
    for(int j = i + 1; j <= 150; j++) {
      data.emplace_back(i * i + j * j, i, j);
    }
  }
  sort(begin(data), end(data));

  while(scanf("%d %d", &H, &W), H) {
    auto p = upper_bound(begin(data), end(data), make_tuple(H * H + W * W, H, W));
    printf("%d %d\n", get< 1 >(*p), get< 2 >(*p));
  }
}

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

const int maxn=2e5+7;
int n,k,c,l[maxn],r[maxn],cnt;
char s[maxn];

int main()
{
	scanf("%d%d%d%s",&n,&k,&c,s+1);
	for(int i=1;i<=n;++i) {
		if(cnt==k+1) break;
		if(s[i]=='x') continue;
		if(cnt==0) {l[++cnt]=i;continue;}
		if(l[cnt]+c>=i) continue;
		l[++cnt]=i;
	}
	cnt=k+1;
	for(int i=n;i>=1;--i) {
		if(cnt==0) break;
		if(s[i]=='x') continue;
		if(cnt==k+1) {r[--cnt]=i;continue;}
		if(r[cnt]-c<=i) continue;
		r[--cnt]=i;
	}
	for(int i=1;i<=k;++i) {
		if(l[i]==r[i]) printf("%d\n",l[i]);
	}
}

Measured memory_bytes: 3200
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }


int main(){
	ll a,v,b,w,t ;
	cin >> a >> v >> b >> w >> t ;
	bool ok ; 
	if(a<=b) ok = (a+v*t>=b+w*t);
	else ok = (a-v*t<=b-w*t) ;
	cout << (ok?"YES":"NO") << endl ;
}

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

using namespace std;
typedef long long ll ;
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define pb push_back

int main()
{
	int n ;
	cin>> n ;
	ll a[n] , sum[n+1] ;
	sum[0]=0 ;
	rep(i,0,n){ cin>>a[i] ; sum[i+1]=sum[i]+a[i] ; }
	ll dp[n][n] ;
	memset(dp,0,sizeof(dp)) ;
	rep(i,0,n-1) dp[i][i+1]=a[i]+a[i+1] ;
	rep(l,3,n+1)
	{
		rep(i,0,n-l+1)
		{
			int j=i+l-1 ;
			dp[i][j]=1e17 ;
			rep(k,i,j)
				dp[i][j] = min(dp[i][j] , dp[i][k]+dp[k+1][j]+sum[j+1]-sum[i]) ;
		}
	}
	cout<<dp[0][n-1]<<endl ;
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    long long N;
    std::cin >> N;
    long long A;
    std::cin >> A;

    N %= 500;
    if (A >= N)
        cout << YES << endl;
    else
        cout << NO << endl;

    return 0;
}


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

int main() {
 string a,b;
 cin>>a>>b;
  int x=stoi(a+b);
  for(int i=0;i<1000;i++){
    if(i*i==x){cout<<"Yes"<<endl;return 0;}}
  cout <<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long x,k,d,n;
int main() {
	cin>>x>>k>>d;
	x=abs(x);
	n=x/d;
	if(n>=k) cout<<x-k*d;
	else {
		k-=n;
		x%=d;
		if(k%2==0) cout<<x;
		else cout<<min(abs(x+d),abs(x-d));
	}
	return 0;
}

Measured memory_bytes: 3612
h,w=map(int,input().split())
G=[list(input()) for i in range(h)]
ans=1
for l in G:
    for i in range(w-1):
        if l[i]==l[i+1]=='#':
            l[i]='o'
            l[i+1]='o'
        if l[i]=='o' and l[i+1]=='#':
            l[i+1]='o'
for k in range(h-1):
    for j in range(w):
        if G[k][j]=='#' and G[k+1][j]=='#':
            G[k][j]='o'
            G[k+1][j]='o'
        elif G[k][j]=='#' and G[k+1][j]=='o':
            G[k][j]='o'
        elif G[k][j]=='o' and G[k+1][j]=='#':
            G[k+1][j]='o'
for l in G:
    if '#' in l:
        ans*=0
if ans==0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(b<a)swap(a,b);
    if(c>=a&&c<=b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
char c;
cin>>c;
if(c>=65&&c<=90) cout<<"A\n";
if(c>=97&&c<=122) cout<<"a\n";
}


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

int main()
{
	long long n;
	cin >> n;
	long long i;
	for(i = sqrt(n); i >= 2; i--){
		if(n % i == 0){
			break;
		}
	}
	cout << i + n / i - 2 << endl;
	return 0;
} 

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

int INF=1001001001;
int N, A, B, C;
vector<int>v;

int dfs(int n,int a, int b, int c){
    if(n==N){
        if(a>0&&b>0&&c>0){
            return abs(a-A)+abs(b-B)+abs(c-C)-30;
        }
        else return INF;
    }
    vector<int>ret(4);
    ret[0]=dfs(n+1, a, b, c);
    ret[1]=dfs(n+1, a+v[n], b, c)+10;
    ret[2]=dfs(n+1, a, b+v[n], c)+10;
    ret[3]=dfs(n+1, a, b, c+v[n])+10;
    int ans=INF;
    rep(i, 4){
        if(ans>=ret[i]){
            ans=ret[i];
        }
    }
    return ans;
}

int main(void){
    cin>>N>>A>>B>>C;
    rep(i, N){
        int s;
        cin>>s;
        v.push_back(s);
    }
    cout<< (dfs(0, 0, 0, 0))<<endl;;
}

Measured memory_bytes: 256
// 基本テンプレート
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int acc[100010];
signed main() {
    int N, K;
    while(cin >> N >> K, N || K) {
        memset(acc, 0, sizeof(acc));
        for(int i=0; i<N; i++) {
            cin >> acc[i+1];
            acc[i+1] += acc[i];
        }

        int ans = -INF;
        for(int i=K; i<=N; i++) {
            chmax(ans, acc[i] - acc[i-K]);
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int X,Y;
cin>>X>>Y;
cout<<X+(Y/2)<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

void pushBall(int c[10][10][10], int top[10][10], int x, int y, int f){
    c[x][y][ top[x][y] ] = f;
    top[x][y]++;
}

void dfs(int n, int m, int x, int y, int z, int ball, int c[10][10][10], int &ans, int k, int dx, int dy, int dz){
    if(ans != -1) return;
    if(c[x][y][z] == ball) k++;
    else return;
    if(k == m){
        ans = ball;
        return;
    }

    int nx = x + dx;
    int ny = y + dy;
    int nz = z + dz;
    if(nx < 0 || nx >= n || ny < 0 || ny >= n || nz >= n || nz < 0) return;
    dfs(n,m,nx,ny,nz,ball,c,ans,k,dx,dy,dz);
}

int check(int c[10][10][10], int top[10][10], int n, int m){
    rep(i,n){
        rep(j,n){
            rep(k,n){
                if(c[i][j][k] == -1) continue;
                int tmp = -1;
                range(x,-1,2) range(y,-1,2) range(z,-1,2){
                    if(x == 0 && y == 0 && z == 0) continue;
                    dfs(n,m,i,j,k,c[i][j][k],c,tmp,0,x,y,z);
                }
                if(tmp != -1) return tmp;
            }
        }
    }
    return -1;
}

int main(){
    int n,m,q;
    while(cin >> n >> m >> q, n||m||q){
        int c[10][10][10]; //Black 0, white 1,
        memset(c,-1,sizeof(c));
        int top[10][10] = {0};
        vector<int> x, y;
        rep(i,q){
            int a, b;
            cin >> a >> b;
            a--; b--;
            x.emplace_back(a);
            y.emplace_back(b);
        }

        bool f = 0;
        rep(i,q){
            pushBall(c,top,x[i],y[i],i % 2);
            int tmp = check(c,top,n,m);
            if(tmp == 0){
                cout << "Black" << ' ' << i + 1 << endl;
                f = 1;
                break;
            }else if(tmp == 1){
                cout << "White" << ' ' << i + 1 << endl;
                f = 1;
                break;
            }
        }
        if(f == 0){
            cout << "Draw" << endl;
        }
    }
}

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

class Bridge {
public:
	vector<vector<int>> G;
	vector<int> ord, low;
	vector<pair<int, int>> bridges;
	int k;

	Bridge(int N):k(0) {
		G.resize(N); ord.resize(N, -1); low.resize(N, -1);
	}
	void clear() { G.clear();ord.clear();low.clear(); }
	void add_edge(int s, int t) {
		G[s].emplace_back(t); 
		G[t].emplace_back(s);
	}

	bool is_bridge(int u, int v)const {
		if (ord[u] > ord[v])swap(u, v);
		return ord[u] < low[v];
	}

	/* Lowlink */
	void dfs(int u,int rev = -1) {
		ord[u] = low[u] = k;
		k++;
		for (auto v : G[u]) {
			if (v == rev)continue;
			if (ord[v] < 0) {
				dfs(v, u);
				low[u] = min(low[u], low[v]);
			}
			else {
				low[u] = min(low[u], ord[v]);
			}
			if (is_bridge(u, v)) {
				int s = u, t = v;
				if (s > t) swap(s, t);
				bridges.push_back({ s,t });
			}
		}
	}

	void solve() {
		dfs(0);
		sort(bridges.begin(), bridges.end());
	}
};

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int V, E; cin >> V >> E;
	Bridge b(V);
	for (int i = 0; i < E;i++) {
		int s, t; cin >> s >> t;
		b.add_edge(s, t);
	}
	b.solve();
	for (auto bridge : b.bridges) {
		cout << bridge.first << " " << bridge.second << endl;
	}
	return 0;
}

Measured memory_bytes: 4364
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

D.sort()
T.sort()

i = 0
ans = "YES"
for e in T:
    flag = True
    while flag:
        if i >= N:
            ans = "NO"
            break
        else:
            if D[i] == e:
                flag = False
            i += 1

    if ans == "NO":
        break
print(ans)


Measured memory_bytes: 35420
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
typedef long long ll;
typedef long double ld;
const ll inf = 999999999999999999;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(a - x) < abs(b - x))
		cout << "A" << endl;
	else
		cout << "B\n";
	getchar(); getchar();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

#include <functional>

template<typename T>
class SegmentTreeAllOne {
    using Func = function<T(T, T)>;

public:
    vector<T> data;
    int n;
    T init;
    Func update_func;
    SegmentTreeAllOne(int _n, T _init, Func up) {
        init = _init;
        update_func = up;
        for (n = 1; n < _n; n *= 2)
            ;
        data.resize(2 * n - 1, init);
    }
    void update(int l, int r, T val) {
        for (l += n - 1, r += n - 1; l < r; l = l / 2, r = (r - 1) / 2) {
            if (!(l & 1)) {
                data[l] = update_func(data[l], val);
            }
            if (!(r & 1)) {
                data[r - 1] = update_func(data[r - 1], val);
            }
        }
    }
    T query(int pos) {
        pos += n - 1;
        T res = data[pos];
        while (pos > 0) {
            pos = (pos - 1) / 2;
            res = update_func(res, data[pos]);
        }
        return res;
    }
};

ll calc(ll diff, ll s, ll t) {
    if (diff > 0) {
        return diff * s;
    } else {
        return diff * t;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    auto SUM = [&](ll a, ll b) {
        return a + b;
    };
    int n, q, s, t;
    cin >> n >> q >> s >> t;
    SegmentTreeAllOne<ll> SegTree(n + 1, 0LL, SUM);
    ll ans = 0, prev = 0;
    REP(i, 0, n + 1) {
        ll v;
        cin >> v;
        SegTree.update(i, i + 1, v);
        ans -= calc(v - prev, s, t);
        prev = v;
    }
    dump(ans);
    REP(i, 0, q) {
        int l, r, v;
        cin >> l >> r >> v;
        ll diff1 = 0, diff2 = 0;
        diff1 = SegTree.query(l) - SegTree.query(l - 1);
        if (r < n) {
            diff2 = SegTree.query(r + 1) - SegTree.query(r);
        }
        ans += calc(diff1, s, t);
        ans += calc(diff2, s, t);
        SegTree.update(l, r + 1, v);
        diff1 = SegTree.query(l) - SegTree.query(l - 1);
        if (r < n) {
            diff2 = SegTree.query(r + 1) - SegTree.query(r);
        }
        ans -= calc(diff1, s, t);
        ans -= calc(diff2, s, t);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 7056
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<int> p;
int main()
{
	int n;
	cin >> n;
	for (int i = 0;i < n;i++)
	{
		int num;
		cin >> num;
		p.push_back(num);
	}
	int oper;
	cin >> oper;
	while (oper--)
	{
		int opr;
		cin >> opr;
		switch (opr)
		{
			int head, end;
		case 0:
			cin >> head >> end;
			int _min;
			_min = p[head];
			for (int i = head;i != end;i++)
			{
				_min = min(_min, p[i]);
			}
			cout << _min << endl;
			break;
		case 1:
			cin >> head >> end;
			int _max = p[head];
			for (int i = head;i != end;i++)
			{
				_max = max(_max, p[i]);
			}
			cout << _max << endl;
			break;

		}
	}
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  int mx = 0;
  rep(i, s.size()){
    bool f = false;
    rep(j, s.size()-i){
      if(s.at(i+j) != t.at(j)){
        f = true;
        break;
      }
    }
    if(f == false){
      mx = s.size() - i;
      break;
    }
  }
  cout << s.size()+t.size()-mx << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <vector>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[argc])
{
  string S;

  cin >> S;

  char prev_c = '0';
  vector<int> flip_index;
  
  FOR(i, S.size()) {
    if (S[i] != prev_c)
      flip_index.push_back(i);
    prev_c = S[i];
  }
  if (S.back() == '1')
    flip_index.push_back(S.size());

  int ans = S.size();
  for(auto i : flip_index) {
    if (MAX(i, S.size() - i) < ans)
      ans = MAX(i, S.size() - i);
  }

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


Measured memory_bytes: 704
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int a, b; readV(a, b);
  writeln([a+b, a-b, a*b].reduce!max);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, k; cin >> a >> b >> k;
    vector<int> v;
    for(int i = 1; i <= __gcd(a, b); i++)
    {
        if(a % i == 0 && b % i == 0) v.push_back(i);
    }
    sort(v.begin(), v.end(), greater<int>());
    cout << v[k - 1] << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
inline int read()
{
    int X=0; bool flag=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
    while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
    if(flag) return X;
    return ~(X-1);
}
 
 int k;
string s="ACL";

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	k=read();
	while(k--){
		cout<<s;
	}


    return 0;
}

Measured memory_bytes: 3596