akhauriyash/Code-Regression huggingface dataset:
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 100
#define mp make_pair
#define mid (l+r)/2
#define le node * 2 
#define ri node * 2 + 1 
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
#define all(x) x.begin(), x.end()
#define gc getchar_unlocked
typedef long long ll;
typedef short int si;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef pair<double,ll>pdi;
const ll inf=2e18;
const ll mod=1e9+7;
const ld Pi=acos(-1) ;
ll n , q ;
vll in  [300009] , out [300009] ;
ll   l  [300009] , r   [300009] , val [300009] ; 
ll tree [1000009] , lzy [1000009] ;
void lzyUpd ( ll node , ll l , ll r ) {
    tree [node] += lzy [node] ;
    if ( l != r ) {
        lzy [le] += lzy [node] ;
        lzy [ri] += lzy [node] ;
    }
    lzy [node] = 0 ; 
}
void upd ( ll node , ll l , ll r , ll s , ll e , ll x ) {
    lzyUpd ( node , l , r ) ;
    if ( s > r || e < l ) return ;
    if ( s <= l && e >= r ) {
        lzy [node] += x ;
        lzyUpd ( node , l , r ) ;
        return ; 
    }
    upd ( le , l , mid , s , e , x ) ;
    upd ( ri , mid + 1 , r , s , e , x ) ;
    tree [node] = max ( tree [le] , tree [ri] ) ;
}
ll query ( ll node , ll l , ll r , ll s , ll e ) {
    lzyUpd ( node , l , r ) ;
    if ( s > r || e < l ) return -inf;
    if ( s <= l && e >= r ) return tree [node] ;
    return max ( query ( le , l , mid , s , e ) , query ( ri , mid + 1 , r , s , e ) ) ; 
}
int main () {

    cin >> n >> q ;
    for ( ll i = 1 ; i <= q ; i ++ ) {
        scanf ("%lld%lld%lld",&l [i] ,&r [i] ,&val [i] ) ;
        in  [l[i]] .pb ( i ) ;
        out [r[i]] .pb ( i ) ; 
    }
    ll ans = 0 , sum = 0 ;  
    for ( ll i = 1 ; i <= n ; i ++ ) {
        for ( auto u : in [i] ) {
            sum += val [u] ; 
        }
        ll dp = sum + query ( 1 , 0 , n , 0 , i - 1 ) ; 
        upd ( 1 , 0 , n , i , i , dp - sum ) ; 
        for ( auto u : out [i] ) {
            sum -= val [u] ;
            upd ( 1 , 0 , n , l [u] , r [u] , val [u] ) ;   
        }
        ans = max ( ans , dp ) ; 
    }
    cout << ans << endl ; 
}



Measured memory_bytes: 43136
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int a, b , c;
        Scanner scanner = new Scanner(System.in);
        a = scanner.nextInt();
        b = scanner.nextInt();
        c = scanner.nextInt();
        scanner.close();

        if ( ((a < c) && (c < b)) || ((b < c) && (c < a))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}

Measured memory_bytes: 22996
#include <stdio.h>

void Do(int N){
  int i, j, S;
  int d[N];
  S = 0;
  for(i = 0;i < N;i++) scanf("%d", &d[i]);
  for(i = 0;i < N;i++) for(j = i + 1;j < N;j++) S += d[i] * d[j];
  printf("%d\n", S);
}
  
int main(void){
  int N;
  scanf("%d", &N);
  Do(N);
  return 0;
}


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

int main(){

    string S;
    cin >> S;

    int sum = 0;

    for(  int i = 0; i < 4; i++){
        if( S[i] == '+' ) sum++;
        else sum--;
    }

    cout << sum << endl;

    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))
#define INF ((1LL<<62)-(1LL<<31))

//next_permutation
void nexp(ll*a,int cnt){
	int l=cnt-1,r=cnt-1;
	ll t;
	while(--l>=0&&a[l]>a[l+1]);
	if(l>=0){
		while(a[l]>a[r])r--;
		t=a[l];a[l]=a[r];a[r]=t;
	}
	for(l++,r=cnt-1;l<r;l++,r--)t=a[l],a[l]=a[r],a[r]=t;
}

ll cost[210][210];
ll dddd[210][210];
 
void waasharuhuroido(ll n){
	rep(i,0,n)rep(j,0,n)dddd[i][j]=i==j?0:cost[i][j]?cost[i][j]:INF;
	rep(k,0,n)rep(i,0,n)rep(j,0,n)dddd[i][j]=min(dddd[i][j],dddd[i][k]+dddd[k][j]);
}
 
int main(){
	int n,m,r,rr[10];
	scanf("%d%d%d",&n,&m,&r);
	rep(i,0,r){
		int t;
		scanf("%d",&t);
		t--;
		rr[i]=t;
	}
	rep(i,0,m){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		a--;b--;
		cost[a][b]=cost[b][a]=c;
	}
	waasharuhuroido(n);
	ll ans=INF,c=1;
	rep(i,1,r+1)c*=i;
	ll index[10]={0,1,2,3,4,5,6,7,8,9};
	rep(nnnn,0,c){
		int t=0;
		rep(i,1,r)t+=dddd[rr[index[i-1]]][rr[index[i]]];
		ans=min(ans,t);
		nexp(index,r);
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  if (n%2) rep(i,m) cout << (i+1) << " " << (n-i) << "\n";
  else rep(i,m) {
    if (i*2+1<n/2) cout << (i+1) << " " << (n-i) << "\n";
    else cout << (i+1) << " " << (n-1-i) << "\n";
  }
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<numeric>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    ll ans=0,x=1,sum=0;
    map<ll,int> m;
    for(ll i=0;i<(ll)s.size();i++){
        sum+=(s[i]-'0')*x;
        sum%=2019;
        m[sum]++;
        x=x*10%2019;
    }
    m[0]++;
    for(auto p : m){
        ans+=p.second*(p.second-1)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3748
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let s = i.read_line().to_string();
    let s = s.as_bytes();
    let w = i.read::<usize>();

    let mut x = 0;
    while x < s.len() {
        write!(o, "{}", s[x] as char).unwrap();
        x += w;
    }
    writeln!(o, "").unwrap();
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }
    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
    }
}


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

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

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

    int q;
    cin >> q;
    vector<int> Q(q);
    map<int, bool> mp; // {value, existed}
    for(int i = 0; i < q; i++){
        cin >> Q[i];
        mp[Q[i]] = false;
    }

    for(int i = 0; i < (1 << n); i++){
        int cost = 0;
        for(int j = 0; j < n; j++){
            if((i >> j) & 1){
                cost += A[j];
            }
        }
        if(mp.count(cost)){
            mp[cost] = true;
        }
    }

    for(int i = 0; i < q; i++){
        cout << (mp[Q[i]] ? "yes" : "no") << endl;
    }

    return 0;
}


Measured memory_bytes: 3216
#include <iostream>

using namespace std;

int main()
{
	int n;
	string S, myString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	cin >> n >> S;
	for (int i = 0; i < S.length(); i++)
		S[i] = myString[(myString.find(S[i])+n)%26];
		
	cout << S << endl;
}


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

int main(){

   string s,t,u;
   int a,b;
   cin>>s>>t;
   cin>>a>>b;
   cin>>u;

   if(s==u){
       cout<<a-1<<" "<<b<<endl;
   }else{
       cout<<a<<" "<<b-1<<endl;
   }

return 0;
}

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

const int INF = 1001001001;

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int,int> > key;
  for(int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    int s = 0;
    for(int j = 0; j < b; j++) {
      int c;
      cin >> c;
      --c;
      s |= 1<<c;
    }
    key.emplace_back(s,a);
  }

  vector<int> dp(1<<n, INF);
  dp[0] = 0;
  for(int s = 0; s < 1<<n; s++) {
    for(int i = 0; i < m; i++) {
      int t = s | key[i].first;
      int cost = dp[s] + key[i].second;
      dp[t] = min(dp[t], cost);
    }
  }
  int ans = dp.back();
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}


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

int check(vector<vector<char>>&hyo,int n,int m){
  vector<int>delh;
  vector<int>delw;
  bitset<6>a=n;
  bitset<6>b=m;
  int ret=0;
  for(int i=0;i<hyo.size();i++){
    for(int j=0;j<hyo.at(0).size();j++){
      if(a.test(i)&&b.test(j)&&hyo.at(i).at(j)=='#')
        ret++;
    }
  }
  return ret;
}

int main(){
  int h,w,n;
  cin >> h >> w >> n;
  vector<vector<char>>hyo(h,vector<char>(w));
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      cin >> hyo.at(i).at(j);
  int ans=0;
  for(int i=0;i<(1<<h);i++){
    for(int j=0;j<(1<<w);j++){
      if(check(hyo,i,j)==n)
        ans++;
    }
  }
  cout << ans  << endl;
  return 0;
}     

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ins insert
#define sz(x) (long long)x.size()
typedef long long ll;
typedef long double ld;
const int N = 1e5 + 5;
const ld pi = 3.141592653;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

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

ll calc (ll a, ll b){
        ll res = 1;
        while(b > 0){
                if(b%2==1) res = (res * a)%MOD;
                a = (a * a)%MOD;
                b = b/2;
        }
        return res;
}

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int T = 1;
        //cin>>T;
        while(T--)
        {
                ll n;
                cin>>n;
                cout<< (calc(10, n) - 2 * calc(9, n) + calc(8,  n) + 10 * MOD) % MOD;
        }
        return 0;
}

Measured memory_bytes: 3644
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>
#include <cmath>
#include <iomanip>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////
const int MOD = 1000000007;

void add (int & a, int b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}

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

    string K;
    int D, N;

    cin >> K;
    cin >> D;
    N = K.size();

    vector<vector<int>> exact(N + 1, vector<int>(D));
    vector<vector<int>> smaller(N + 1, vector<int>(D));    

    exact[0][0] = 1;

    for (int i = 1; i <= N; i++) {
        int dig = K[i-1] - '0';

        for (int j = 0; j < D; j++) {
            add(exact[i][(j + dig) % D], exact[i-1][j]);

            for (int k = 0; k <= 9; k++) {
                add(smaller[i][(j + k) % D], smaller[i-1][j]);
                if (k < dig)
                    add(smaller[i][(j + k) % D], exact[i-1][j]);
            } 
        }

        // for (int j = 0; j < D; j++) {
        //     if (exact[i][j]) {
        //         cerr << i << " " << j << " = " << exact[i][j] << "\n";
        //     }
        //     if (smaller[i][j]) {
        //         cerr << "sm " << i << " " << j << " = " << smaller[i][j] << "\n";
        //     }
        // }
    }

    int res = (exact[N][0] + smaller[N][0]) % MOD;
    res = (res + MOD - 1) % MOD;
    cout << res << "\n"; 

    return 0;
}


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

ll f(ll x, map<ll, ll>& m) {
  if (x == 1)
    return 1;
  ll nx = x / 2;
  if (m.find(nx) == m.end())
    m.emplace(nx, f(nx, m));
  return 1 + 2 * m[nx];
}

int main() {
  ll h;
  cin >> h;

  map<ll, ll> m;

  cout << f(h, m) << endl;
}

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

using namespace std;

typedef pair<int,int> P;

int n,m;
/*
bool operator == (const P &a, const P &b)const
{
	return (a.first == b.first) & (a.second == b.second);
}
*/
void solve()
{
	vector<P> model(n);
	vector<P> dist(n);
	for(int i = 0; i < n; i++)
		cin >> model[i].first >> model[i].second;
	for(int i = 0; i < n; i++){
		dist[i] = P(model[0].first - model[i].first, model[0].second - model[i].second);
		//cout << dist[i].first << ' ' << dist[i].second << endl;
	}
	sort(dist.begin(), dist.end() );

	cin >> m;
	vector<P> some(m);
	for(int j = 0; j < m; j++){
		cin >> some[j].first >> some[j].second;
	}

	for(int i = 0; i < m; i++){
		int c = 0;
		for(int j = 0; j < m; j++){
			P sdist = P(some[i].first - some[j].first, some[i].second - some[j].second);
			if(binary_search(dist.begin(), dist.end(), sdist)){
				c++;
				
			}
		}
		if(c == n){
			cout << some[i].first - model[0].first<< ' ' << some[i].second - model[0].second<< endl;
			break;
		}
		

	}




}

int main(void)
{
	while(cin >> n, n)
		solve();
	return 0;
}

Measured memory_bytes: 1208
N = int(input())
*X, = map(int,input().split())

mod = 10**9+7

ans = 0
f = 1
for i in range(2,N):
    f *= i
    f %= mod
cnt = 0
for i,x in enumerate(X[:-1],1):
    tmp = f * pow(i,mod-2,mod)
    cnt += tmp
    cnt %= mod
    ans -= tmp*x
    ans %= mod
ans += cnt*X[-1]%mod
ans %= mod
print(ans)

Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define INF 0x3f3f3f3f
typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<double,double> pdd;
ll n,k;
map<ll,ll> m;
int main()
{
    //IOS;
    while(cin>>n)
    {
        rep1(i,n)
        {
             ll tmp;
             cin>>tmp;
             m[tmp]=i;
        }
        rep1(i,n) cout<<m[i]<<' ';
        cout<<'\n';
    }


    return 0;
}



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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル

	int N, K;
	cin >> N >> K;

	vi sunuke(N,0);
	rep(i,K){
		int di;
		cin >> di;
		rep(j,di){
			int temp;
			cin >> temp;
			temp--;
			sunuke[temp]++;
		}
	}

	int ans = 0;
	rep(i,N){
		if(sunuke[i] == 0){
			ans++;
		}
	}

	cout << ans << endl;

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define LOOP(i,x,n) for(int i=(x);i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e11;


signed main(){
  int n,d,x;
  cin>>n>>d>>x;
  int sum=0;
  REP(i,n){
    int a;cin>>a;
    int p=0;
    while(a*p+1<=d){
      sum++;
      p++;
    }
  }

  cout<<sum+x<<endl;
  return 0;
}


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

#define ll   long long int
#define PI 3.14159265358979
#define zig ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;


int main()
{
    zig
    ll n, i, minm=1010000000000000, sum;
    cin>>n;
    vector<ll> vec(n);
    for(auto &i: vec)
        cin>>i;
    sort(vec.begin(), vec.end());
    for(i=vec[0]; i<=vec[n-1]; i++)
    {
        sum=0;
        for(auto j:vec)
        {
            sum+=((i-j)*(i-j));
        }
        minm=min(sum, minm);
    }
    cout<<minm<<'\n';
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
V<ll>m[11];
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n;cin>>n;
    ll cnt=0;
    for(int bit=0;bit < (1<<n); bit++)
    {
        cout<<cnt<<":";
        for(int i=0;i<n;i++)
            if(bit & (1<<i))
            {
                cout<<" ";
                cout<<i;
            }
        cout<<endl;
        cnt++;
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a.at(i);
    int ans=LONG_LONG_MAX;
    for(int i=-100; i<=100; i++){
        int sum=0;
        rep(j,n){
            sum+=(a.at(j)-i)*(a.at(j)-i);
        }
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
}

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

typedef long long ll;
typedef pair<int, int> ii;

const int N = 5010;
int d[N];
int dm[N];
int zero[N];
ll sum[N];
int n, x, m;

int k, q;

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

    cin >> k >> q;
    for (int i = 0; i < k; ++i) {
      cin >> d[i];
    }
    // query
    for (int i = 0; i < q; ++i) {
      cin >> n >> x >> m;
      // seq: x, x + d0 , x + d0 + d1, x + d.....
      // find aj % m < aj+1 % m
      // gt: aj / m + 1 == aj+1 / m
      // eq: d % k == 0, d % m == 0

      x %= m;
      sum[0] = 0, zero[0] = 0;
      for (int j = 0; j < k; ++j) {
        dm[j] = d[j] % m;
        sum[j + 1] = sum[j] + dm[j];
        zero[j + 1] = zero[j] + (dm[j] == 0);
      }
      int a = (n - 1) / k * zero[k] + zero[(n - 1) % k];
      int b = ((n - 1) / k * sum[k] + sum[(n - 1) % k] + x) / m - x / m;
      int ans = (n - 1) - a - b;
      cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	long long N;
	//cin >> N;

	string s ,t;
	cin >> s >> t;

	//int A[5]
	//sort(A, A + 5);
	long long count = 0;
	for (long long i = 0; i < s.length(); i++)
	{
		if (s[i] != t[i])
		{
			count++;
		}
	}
	if (true)
	{
		cout << count << endl;
	}
	else
	{
		cout << "No" << endl;
	}

}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int w, h;
vector<int> ans;

void dfs(int x, int y, vector<vector<int>> &m, vector<vector<bool>> &seen);

int main()
{
    while (true)
    {
        cin >> w >> h;
        // 終了条件
        if ((w == 0) && (h == 0))
        {
            break;
        }
        vector<vector<int>> m(52, vector<int>(52, 0));
        vector<vector<bool>> seen(52, vector<bool>(52, false));
        // データの受け取り
        rep(1, i, h + 1)
        {
            rep(1, j, w + 1)
            {
                cin >> m.at(i).at(j);
            }
        }
        int count = 0;
        //すべての点で探索
        rep(1, i, h + 1)
        {
            rep(1, j, w + 1)
            {
                // 探索済か海のマスならとばす
                if (seen.at(i).at(j) || (m.at(i).at(j) == 0))
                {
                    continue;
                }
                // dfsによる塗りつぶし
                dfs(i, j, m, seen);
                count++;
            }
        }
        ans.push_back(count);
    }
    for (auto a : ans)
    {
        cout << a << endl;
    }
}

void dfs(int x, int y, vector<vector<int>> &m, vector<vector<bool>> &seen)
{
    // 探索済か海のマスなら探索終了
    if (seen.at(x).at(y) || (m.at(x).at(y) == 0))
    {
        return;
    }
    // 探索済の印をつける
    seen.at(x).at(y) = true;
    rep(-1, dx, 2)
    {
        rep(-1, dy, 2)
        {
            dfs(x + dx, y + dy, m, seen);
        }
    }
    return;
}


Measured memory_bytes: 3344
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n;
  cin >> n;
  char c[n];
  ll r=0,w=0;
  for(ll i=0;i<n;i++){
    cin >> c[i];
    if(c[i]=='R')r++;
    else w++;
  }

  ll k=0;
  for(ll i=0;i<r;i++)if(c[i]=='R')k++;

  cout << r-k << endl;
  
  

}

Measured memory_bytes: 3824
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        String s = sc.next();
        String t = sc.next();
        int max = 0;
        for (int i = 0; i < n; i++) {
            int tmp = 1;
            int itr = 1;
            if (s.charAt(i) == t.charAt(0)) {
                for (int j = i + 1; j < n; j++) {
                    if (s.charAt(j) == t.charAt(itr)) {
                        tmp++;
                    } else {
                        break;
                    }
                    itr++;
                }
                if (tmp > max) max = tmp;
            }
        }
        System.out.println(n * 2 - max);
    }

}


Measured memory_bytes: 22740
N = int(input())
A, B, C = [0]*N, [0]*N, [0]*N 
for i in range(N):
    A[i], B[i], C[i] = [int(j) for j in input().split()]
    
dp = [[0]*3 for _ in range(N+1)]

for i in range(N):
    dp[i+1][0] = max(dp[i][1], dp[i][2]) + A[i]
    dp[i+1][1] = max(dp[i][0], dp[i][2]) + B[i]
    dp[i+1][2] = max(dp[i][0], dp[i][1]) + C[i]
    
print(max(dp[-1]))

Measured memory_bytes: 34656
main = getLine >>= main' . read . last . words
    where
        main' x = getLine >>= print . solve x . map read . words

solve :: Int -> [Int] -> Int
solve x = rec
    where
        rec (a : b : cs)
            | a + b > x && x >= a = a + b - x + rec (x - a : cs)
            | a + b > x = a - x + b + rec (0 : cs)
            | otherwise = rec (b : cs)
        rec _ = 0


Measured memory_bytes: 36220
// AtCoder Beginner Contest - Problem A: Programming Education (https://beta.atcoder.jp/contests/abc112/tasks/abc112_a)
#include <bits/stdc++.h>

using namespace std;

void solve(int N, int A, int B)
{
    if (N == 1)
        cout << "Hello World\n";
    else
        cout << A + B << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, A, B;
    cin >> N >> A >> B;

    solve(N, A, B);

    return 0;
}


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


int main(){
  string S;
  cin >> S;
  if(S=="Sunny"){
    cout << "Cloudy";
  }else if(S=="Cloudy"){
    cout << "Rainy";
  }else if(S=="Rainy"){
    cout << "Sunny";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll     long long int 
#define pb     push_back
#define umap   unordered_map
#define mod    1000000007
#define all(x) (x).begin(), (x).end()
//__builtin_popcount(x)
//__builtin_parity(x)   =(number of set bits)%2
//__builtin_clz(x)      to count the number of leading  zeroes 
//__builtin_ctz(x)      to count the number of trailing zeroes 
//__gcd(a,b)
using namespace std;
int main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 int n;cin>>n;
 int x=n%10;
 if(x==1 || x==3 || x==7 || x==9)
 {
  int y=1;
  ll rem=7%n;
  for(int k=1;k<=1e6;k++)
  {
     if(rem==0)
       {cout<<k;y=0;break;}
     else
       {
        rem=((((rem*10)%n)+(7%n))%n);
       }
  }
  if(y)
    cout<<-1;
 }
 else
 {
  cout<<-1;
 }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
ll MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}
ll modpow(ll x, ll y, ll m) {
    if (y == 0) return 1;
    ll res = modpow(x, y / 2, m);
    return res * res % m * (y & 1 ? x : 1) % m;
}
ll modinv(ll x) { return modpow(x, MOD - 2, MOD); }

int main(){
    ll H, N; cin >> H >> N;
    ll sum = 0;
    rep(i,N) {
        ll a;
        cin >> a;
        sum += a;
    }
    if(sum >= H) print("Yes");
    else print("No");
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <queue>
#include <stack>
#include <list>
#include <bitset>
#include <deque>
#include <cmath>
#include <iomanip>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define MCLR(a) memset((a), -1 ,sizeof(a))
#define SZ(a) (sizeof(a))
#define FILL(a,v) fill((int*)a,(int*)(a+(SZ(a)/SZ(*(a)))),v)
#define SORT(c) sort((c).begin(),(c).end())

bool cheak(int x, int y, int xMax, int yMax)
{
	return x >= 0 && y >= 0 && xMax > x && yMax > y;
}
const int dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;
const int INF    = 2147483647;

map<ull, ull> a;
ull A[300010];
ull b[300010];
ull c[300010];

int main()
{
	int n,m;

	cin >> n;
	A[0] = 0;
	FOR(i,1,n+1)
	{
		cin >> A[i];
	}
	ull sum = 0;
	sort(A,A+n+1);
	REP(i, n+1)
	{
		sum += A[i];
		if (i == n || A[i] != A[i+1])
			a[sum] = i;
	}
	cin >> m;
	REP(i, m)
		cin >> b[i];
	REP(i, m)
		cin >> c[i];

	REP(i, m)
	{
		map<ull, ull>::iterator tmp = a.lower_bound(c[i]);

		if (tmp != a.end() && A[tmp->second] <= b[i])
			cout << "Yes" << endl;
		else
			cout << "No"  << endl;

	}


	return 0;
}

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

const int maxn = 500005;
int a[maxn], last[maxn], ans[maxn];

bool cmp(vector<int> &a, vector<int> &b) {
	return a[1] < b[1];
}

int f[maxn];
void upd(int id, int val) {
	while(id < maxn) f[id] += val, id += id&-id; 
}
int sum(int id) {
	int res = 0;
	while(id > 0) res += f[id], id -= id&-id;
	return res;
}


signed main() {
	//freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int n, q;
	cin >> n >> q;
	
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	for(int i = 0; i < maxn; i++) {
		last[i] = -1;
	}
	
	vector<vector<int>> query(q, vector<int>(3));
	
	for(int i = 0; i < q; i++) {
		cin >> query[i][0] >> query[i][1];
		--query[i][0], --query[i][1];
		query[i][2] = i;
	}
	
	sort(query.begin(), query.end(), cmp);
	
	int idx = 0;
	for(int i = 0; i < n; i++) {
		
		if(last[a[i]] != -1)
			upd(last[a[i]]+1, -1);
		
		last[a[i]] = i;
		
		upd(i+1, 1);
		
		while(idx < q && query[idx][1] == i) {
			ans[query[idx][2]] = sum(query[idx][1] + 1) - sum(query[idx][0]);
			idx++;
		} 
	}
	
	for(int i = 0; i < q; i++) {
		cout << ans[i] << "\n";
	}
	
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
using Graph = vector<vector<ll>>;
#define all(x) (x).begin(), (x).end() //string の sort とかはこれ
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18;                    //1*10^18
const double PI = 3.141592653589793238; //18桁
const ll MAX = 1e6;
long long fac[MAX], finv[MAX], inv[MAX];

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

// テーブルを作る前処理
void COMinit() //MODは素数じゃないとだよ！！
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  // COMinit();
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, ans = 0;
  ll h[5], m[5], k, me = 0;
  cin >> h[0] >> m[0] >> h[1] >> m[1] >> k;
  me = (h[1] - h[0]) * 60 + (m[1] - m[0]);
  cout << me - k << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define PI 		    acos(-1)
#define pb          push_back
#define ins         insert
#define INF         LLONG_MAX
#define mk          make_pair
#define lb(v,x)     lower_bound(all(v),x)
#define ub(v,x)     upper_bound(all(v),x)
#define ff          first
#define ss          second
#define rev         reverse
#define umap        unordered_map
#define endl        "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a)       (ll)a.size()
#define double      long double
#define minpq       priority_queue <ll,vector<ll>,greater<ll> > 
#define fill(x,y)   memset(x,y,sizeof(x))
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define MOD         1000000007 //1e9+7
#define bp(n)       __builtin_popcountll(n)
#define mxt(a)      *(max_element(a.begin(),a.end()))
#define mnt(a)      *(min_element(a.begin(),a.end())
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i, a, b) for(ll i = (a); i<= (b); ++i)
#define trav(a, x) 	 for(auto &a : x)
#define re(i,n)      for(ll i = 0; i < n; ++i) 
const int N = 4e5 + 7;
typedef pair<ll,ll>   pii;
typedef vector<pii>   vpii;
typedef vector<ll>    vll;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int dx[8]={+1, +1, +1, 0, 0, -1, -1, -1};
int dy[8]={+1, 0, -1, +1, -1, +1, 0, -1};
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
template<typename T> T gcd(T a,T b){ if(a==0) return b; return gcd(b%a,a); }
template<typename T> T powm(T a,T b, ll m){T cnt=1; while(b>0){ if(b%2==1) cnt=(cnt*a)%m; b/=2; a=(a*a)%m; }return cnt%m;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll sqr(ll x) { return x * x;}
// always use 1ll*ans to avoid signed integer overflow; 
void prec(){
		
}
void solve(){	
	string s;cin>>s;
	for(int i=0; i<sz(s); ++i){
		if(s[i]=='?') s[i]='D';
	}
	cout<<s<<endl;
}

int main()
{
    cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
    int tc=1;
    //cin>>tc;
    prec();
    re(i,tc)
    	solve();
    return 0; 
}

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

int main(){
    long long n,m;
    cin >> n >> m;
    int t=(int)sqrt(m);
    int ans=1;
    for(int i=1;i<=t;i++){
        if(m%i==0){
            int l=m/i;
            if(n*l<=m){
                if(l>ans)
                ans=l;
            }
            if(n*i<=m){
                if(i>ans)
                ans=i;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

int subserch(long long* B,long long i, int left,int right){
 //std::cout<<"subserch "<<left<<" "<<right<<std::endl;
 if(std::abs(left-right)<=3){
  for(int j=left;j<right;j++){
   if(B[j]>i){
    return j-1;
   }
  }
  return right-1;
 }
 int mid=left+right;
 mid/=2;
 if(B[mid]<i){
  return subserch(B,i,mid+1,right);
 }else if(B[mid]>i){
  return subserch(B,i,left,mid);
 }else{
  return mid;
 }
}

int serch(long long* B,long long M,int i){
 int left=0;
 int right=M;
 return subserch(B,i,left,right);
 
}

int main(){
 int N,M,K;
 std::cin>>N>>M>>K;

 long long* A=new long long[N];
 long long* B=new long long[M];
 for(int i=0;i<N;i++){
  std::cin>>A[i];
 }
 for(int i=0;i<M;i++){
  std::cin>>B[i];
 }
 for(int i=1;i<M;i++){
  B[i]=B[i-1]+B[i];
 }


 //std::cout<<"hoge\n";
 int forn=0;
 int ans=0;
 int tmp=0;
 for(int i=0;i<=N;i++){
  tmp=serch(B,M,K-forn);
  //std::cout<<i<<" "<<tmp<<std::endl;
  tmp+=i+1;
  if(ans<tmp){
   ans=tmp;
  }
  if(i==N){
   break;
  }
  forn+=A[i];
  if(forn>K){
   break;
  }
  
 }
 
 std::cout<<ans<<std::endl;

 return 0;
}

Measured memory_bytes: 6796
n,x = map(int,input().split())

a,p = [1],[1]
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def f(n,x):
    if n==0:
        return 0 if x <= 0 else 1
    elif x <= 1 + a[n-1]:
        return f(n-1,x-1)
    else:
        return p[n-1] + 1 + f(n-1,x-2-a[n-1])

print(f(n,x))

Measured memory_bytes: 3064
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner yomi = new Scanner(System.in);
        int hito = yomi.nextInt();
        int densyatin = yomi.nextInt();
        int taxiuntin = yomi.nextInt();
        if (hito * densyatin > taxiuntin) System.out.println(taxiuntin);
        else System.out.println(hito * densyatin);

    }
}


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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    // 処理
    int cnt = 0, tmp = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            tmp = x - (500 * i + 100 * j);
            if (tmp % 50 == 0 && tmp / 50 <= c && tmp >= 0) {
                cnt++;
            }
        }
    }

    // 出力
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

X, N = mapint()
A = set(range(1000))
Ps = list(mapint())
Ps = sorted(list(A-set(Ps)))
mi = 10**18
ans = 0
for p in Ps:
    if abs(X-p)<mi:
        ans = p
        mi = abs(X-p)

print(ans)

Measured memory_bytes: 62396
N=int(input())
D=[list(map(int,input().split())) for _ in range(N)]
flag=False
for i in range(N-2):
    if D[i][0]==D[i][1]:
        if D[i+1][0]==D[i+1][1] and D[i+2][0]==D[i+2][1]:
            flag=True
            break

if flag: print("Yes")
else: print("No")


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

// time and space = O(N*W)

int main(){
	
	ll N,W;
	cin >> N >> W;
	ll w[N], v[N];

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

	ll dp[W+1][N+1];
	// dp[i][j] ---> max value when we have last j items and i as max capacity
	
	for(int i=0;i<=N;i++) dp[0][i] = 0;
	for(int i=0;i<=W;i++) dp[i][0] = 0;

	for(int i=1;i<=W;i++){
		for(int j=1;j<=N;j++){

			ll a=0,b=0;
			if(w[N-j]<=i) a = v[N-j] + dp[i-w[N-j]][j-1];
			b = dp[i][j-1];
			dp[i][j] = max(a, b);
		}
	}
	// for(int i=0;i<=W;i++){
	// 	for(int j=0;j<=N;j++) cout << dp[i][j] << " ";
	// 		cout << endl;
	// }
	cout << dp[W][N] << endl;

	return 0;
}

Measured memory_bytes: 82488
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char c;
		String str;
		str = sc.next();
		c = str.charAt(0);
		if((c >= 'a')&&(c <= 'z')){
			System.out.println("a");
		}else if((c >= 'A')&&(c <= 'Z')) {
			System.out.println("A");
		}
		
		sc.close();

	}

}

Measured memory_bytes: 35640
k = int(input())

s = input()

'''
k = 40
s = 'ferelibenterhominesidquodvoluntcredunt'
#s = "nikoandsolstice"
'''
nagasa = len(s)

if nagasa <= k:
    print(s)
elif nagasa > k:
    print(s[ :k] + '...')










Measured memory_bytes: 9164
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

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

    vector<ll> cnt(N, 1);
    vector<bool> used(N, false);
    used[0] = true;
    for(int i = 0; i < M; i++){
        ll x, y;
        cin >> x >> y;

        cnt[x-1] --;
        cnt[y-1] ++;

        if(used[x-1]) used[y-1] = true;
        if(cnt[x-1] == 0) used[x-1] = false;

    }

    ll ans = 0;
    for(int i = 0; i < N; i++){
        if(used[i] ){
            ans ++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
N=int(input())
ans=[0 for _ in range(10050)]
for x in range(1,105):
    for y in range(1,105):
        for z in range(1,105):
            v=x**2+y**2+z**2+x*y+y*z+z*x
            if v<10050:
                ans[v]+=1

for i in range(N):
    print(ans[i+1])

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;


int main(){
    ll a,b,x;cin >>a>>b>>x;
    ll ans=0;
    ans+=b/x+1;
    ans-=(a%x==0)?a/x:a/x+1;
    cout <<ans<<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;
using ll = long long;
using P = pair<int, int>;

const int MAX = 2000005;
const ll MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long pow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

int main() {
    int k;
    string s;
    cin >> k >> s;
    int n = s.size();
    ll ans = 0;
    COMinit();
    rep(i, k+1) {
        ll tmp = pow(25ll, (ll)i) * COM(i+n-1, n-1) % MOD;
        tmp *= pow(26ll, (ll)(k-i));
        tmp %= MOD;
        ans += tmp;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 51156
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define ll long long
#define l long
#define all(x) x.begin(),x.end()
#define pb push_back
#define len(x) x.len
int main()
{unordered_map<int,int> g;
int x,n;
int p[n];
cin>>x>>n;
FOR(i,n)cin>>p[i];
FOR(i,n)g[p[i]]=1;
int i=0;
while(1)
{
    if(g.find(x-i)==g.end()){cout<<x-i;goto end;}
    else if(g.find(x+i)==g.end()){cout<<x+i;goto end;}
    else i++;
}
end:;


return 0;}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	ll ans=0;
	map<pair<char,char>,ll> mp;
	rep(i,1,n+1){
		string s=to_string(i);
		char a=s[0];
		char b=s[s.size()-1];
		mp[pair<char,char>(a,b)]++;
	}
	for(auto &c:mp){
		char p=c.first.first;
		char q=c.first.second;
		ll b=c.second;
		ll k=mp[pair<char,char>(q,p)];
		//cout<<"p:"<<p<<" q:"<<q<<" b:"<<b<<"  "<<b*k<<endl;
		ans+=b*k;
		//.erase(pair<char,char>(q,p));
	}
	cout<<ans;
	return 0;
}

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

bool isPrime[555555];
int prime[555555];
int total;

void seive(int Max)
{
    total=0;
    memset( isPrime , true , sizeof( isPrime ));
    isPrime[0 ] = false ;
    isPrime[1] = false ;
    for ( int i = 2 ; i <= Max ; i++ )//遍历筛去所有最大因数是i的合数
    {
        if ( isPrime[i] )
            prime[ ++ total ] = i ;//把素数记录下来
             //遍历已知素数表中比i的最小素因数小的素数，并筛去合数
        for ( int j = 1 ; j <= total && i * prime[j] <= Max ; j++)
        {
            isPrime[ i * prime[j] ] = false ;
            if  (!( i % prime[j]))
                break;//找到i的最小素因数
        }
    }
}

int main()
{
    int n,i;
    scanf("%d",&n);
    seive(555555);
    i=n;
    for(int x=1;i>0;x+=10)
        if(isPrime[x])
        {
            if(i==n)
                printf("%d",x);
            else
                printf(" %d",x);
            i--;
        }
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
	int i,j,height[10],backup;
	for(i=0;i<10;i++){
		scanf("%d",&height[i]);
	}
	for(j=0;j<10;j++){
		for(i=0;i<9;i++){
				if(height[i]>height[i+1]){
				backup=height[i];
				height[i]=height[i+1];
				height[i+1]=backup;
			}
		}
	}
	for(i=0;i<3;i++){
		printf("%d\n",height[9-i]);
	}
    return 0;
}

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

using namespace std;
typedef long long llint;

const int maxn = 4010;
const char ls[] = "RGB";

int n;
char niz[maxn];
int cnt[200];

int main() {
    scanf("%d%s", &n, niz);
    llint sol = 0;
    int suma = 0;
    for (int i = 0; i < 3; i++) suma += ls[i];
    for (int i = 0; i < n; i++) {
        memset(cnt, 0, sizeof cnt);
        for (int j = 0; j < i; j++) {
            if (niz[i] == niz[j]) continue;
            cnt[niz[j]]++;
        }

        llint tren = 0;
        for (int j = i + 1; j < n; j++) {
            if (niz[i] == niz[j]) continue;

            int ind = 2 * i - j;
            if (ind >= 0 && ind < i && niz[i] != niz[ind] && niz[j] != niz[ind]) tren += cnt[suma - niz[i] - niz[j]] - 1;
            else tren += cnt[suma - niz[i] - niz[j]];
        }
        sol += tren;
    }
    printf("%lld", sol);
    return 0;
}


Measured memory_bytes: 3792