akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  ll N;
  cin >> N;
  vi yakusuu;
  ll ans = 0;
  int sqN = (int)sqrt(N);
  for(int i = 1;i <= sqN;i++ ) {
    if(N % i == 0) {
      yakusuu.push_back(i);
    }
  }
  rep(i,sz(yakusuu)) {
    ll b = (N / yakusuu[i]) - 1;
    if(b > yakusuu[i]) ans+= b;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
#include <cstdint>
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; }

const int INF=1001001001;
const int mod = 1000000007;

int main() {
  int64_t H,W;
  cin>>H>>W;
  int64_t MIN=1e18;
  for(int i=0;i<2;i++){
    for(int h=1;h<=H-1;h++){
      { 
        int64_t SA=h*W;
        int64_t w=W/2;
        int64_t SB=(H-h)*w;
        int64_t SC=(H-h)*(W-w);
        int64_t x=max({SA,SB,SC})-min({SA,SB,SC});
        chmin(MIN,x);
        //cout<<SA<<" "<<SB<<" "<<SC<<endl;
      }//cout<<MIN<<endl;
      { 
        int64_t SA=h*W;
        int64_t h2=(H-h)/2;
        int64_t SB=h2*W;
        int64_t SC=(H-h-h2)*(W);
        int64_t x=max({SA,SB,SC})-min({SA,SB,SC});
        chmin(MIN,x);
        //cout<<SA<<" "<<SB<<" "<<SC<<endl;
      }//cout<<MIN<<endl;
    }
    swap(H,W);
  }
  cout<<MIN<<endl;
  return 0;
}

Measured memory_bytes: 3636
import java.util.*;
  public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        if(X>=30){
          System.out.println("Yes");
        }else if(X<30){
          System.out.println("No");
        }
    }
  }

Measured memory_bytes: 35756
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

char tmp_str[2][100005];

int solve(){
  string s,t;
  cin>>s>>t;

  if(s.size() == t.size()){
    if(s==t) return 1;
    else return 0;
  }

  int r = 1;
  int cur = t.size();
  while(s.size() >= cur){
    cur += (cur+1)*t.size();
    r++;
  }

  auto f = [&](int x){
    if(x==0) return true;
    auto s1 = tmp_str[0];
    auto s2 = tmp_str[1];
    int p_size = 0;
    int q_size = 0;
    rep(i,x){
      q_size = 0;
      rep(j,p_size) s2[q_size++] = s1[j];
      rep(j,t.size()){
        s2[q_size++] = t[j];
        rep(k,p_size) s2[q_size++] = s1[k];
      }
      swap(s1, s2);
      swap(p_size, q_size);
    }
    // dbg(x,string(s1, s1+p_size));
    int is=0,it=0;
    while(is<s.size() && it<p_size){
      if(s[is] == s1[it]){
        is++; it++;
      } else {
        is++;
      }
    }
    return it == p_size;
  };

  int l=0;
  while(r-l>1){
    int mid = (l+r)/2;
    if(f(mid)) l = mid;
    else r = mid;
  }
  return l;
}


int main(){
  cout << solve() << endl;

  return 0;
}



Measured memory_bytes: 3392
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var AB, BC int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d", &AB, &BC)

	fmt.Println(AB * BC / 2)
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

typedef long long LL;

std::vector<int> calcDistance(int nodeNum, std::map<int, std::vector<int>> edge, int startIndex);

using namespace std;
int main()
{
#ifdef LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    int N;
    cin >> N;

    std::map<int, vector<int>> ab;
    for(int i=0;i<N-1;i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        if(ab.count(a) != 0){
            ab[a].push_back(b);
        }
        else{
            ab[a] = {b};
        }

        if(ab.count(b) != 0){
            ab[b].push_back(a);
        }
        else{
            ab[b] = {a};
        }
    }

    std::vector<int> distanceF = calcDistance(N, ab, 0);
    std::vector<int> distanceS = calcDistance(N, ab, N-1);

    int countF = 0;
    int countS = 0;
    for(int i=0;i<N;i++){
        if(distanceF[i] <= distanceS[i]){
            countF++;
        }
        else{
            countS++;
        }
    }

    if(countF > countS){
        cout << "Fennec" << endl;
    }
    else{
        cout << "Snuke" << endl;
    }

    return 0;
}
std::vector<int> calcDistance(int nodeNum, std::map<int, vector<int>> edge, int startIndex){
    std::vector<int> ret;
    ret.resize(nodeNum, -1);
    ret[startIndex] = 0;

    std::queue<int> queue;
    queue.push(startIndex);

    while(!queue.empty()){
        int node = queue.front();
        queue.pop();

        for(auto iter:edge[node]){
            if(ret[iter] == -1){
                ret[iter] = ret[node] + 1;
                queue.push(iter);
            }
        }
    }

    return ret;
}

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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

//---------------------------------------------------------------
//---------------------------------------------------------------

int N;

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

	cin >> N;
	int ans = 0;
	if(N/1000 == 2)	ans++;
	if((N/100) % 10 == 2) ans++;
	if((N/10) % 10 == 2) ans++;
	if(N % 10 == 2) ans++;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int c[105][105];

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int H,W; cin >> H >> W;
    int x = 0;
    int y = 0;
    int color = 1;

    int N; cin >> N;
    REP(i,N)
    {
        int tmp; cin >> tmp;
        REP(j,tmp)
        {
            dump(x)
            dump(min(2*H-1-x,x))
            dump(y)
            c[min(2*H-1-x, x)][y] = color;

            if(x == H-1) y++;
            if(x == 2*H-1) y++;

            if(x != 2*H-1) x++;
            else x = 0;

        }
        color++;
    }

    REP(i,H)
    {
        REP(j,W)
        {
            cout << c[i][j] << " ";
        }
        cout << endl;
    }



}


Measured memory_bytes: 384
N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[1 for i in range(N)]

for i in range(M):
  a,b=map(int,input().split())
  if H[a-1]<=H[b-1]:
    A[a-1]-=A[a-1]
  if H[a-1]>=H[b-1]:
    A[b-1]-=A[b-1]

print(str(sum(A)))

Measured memory_bytes: 20020
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
 
int main(){
	int a,b; cin>>a>>b;
    cout<<max(max(a,b)*2-1,a+b)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<string.h>
#include<queue>
using namespace std;
typedef pair<int,int>P;

long long comb(int n,int r){
    long long ans=1;
    for(int i=0;i<r;i++){
        ans*=n;
        n-=1;
    }
    int R=r;
    for(int i=0;i<R;i++){
        ans/=r;
        r-=1;
    }
    return ans;
}

int main(){
    int n;cin>>n;
    string s;
    vector<string>t;
    for(int i=0;i<n;i++){
        cin>>s;
        sort(s.begin(),s.end());
        t.push_back(s);
    }
    int count=1;
    sort(t.begin(),t.end());
    vector<int>ans;
    for(int i=0;i<t.size()-1;i++){
        if(t[i]==t[i+1]){
            count++;
        }
        else{
            ans.push_back(count);
            count=1;
        }
        if(i==t.size()-2){
            ans.push_back(count);
        }
    }
    long long a=0;
    for(int i=0;i<ans.size();i++){
        a+=comb(ans[i],2);
    }
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 6644
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define PI acos(-1)

int main(){
    int n ,q,a,b;
    cin >> n >> q;
    vector<long long> point(n + 1,0);
    vector<vector<int>> route(n + 1);
    for(int i = 0;i < n - 1;i++){
        cin >> a >> b;
        route[a].push_back(b);
        route[b].push_back(a);
    }

    for(int i = 0;i < q;i++){
        cin >> a >> b;
        point[a] += b;
    }

    queue<int> que;
    vector<int> dist(n + 1,-1);

    que.push(1);
    dist[1] = 0;
    while(!que.empty()){
        int now = que.front();
        que.pop();
        for(int i = 0;i < route[now].size();i++){
            if(dist[route[now][i]] != -1)continue;
            dist[route[now][i]] = dist[now] + 1;
            point[route[now][i]] += point[now];
            que.push(route[now][i]);
        }
    }
    for(int i = 1;i <= n;i++){
        cout << point[i];
        if(i != n)cout << " ";
        else cout << endl;
    }
}


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

using namespace std;

struct DATA{
  int number;
  int count;
};

void PushWordCount(int, vector<DATA>&);
bool Compare(const int&, const int&);

int main(){
  int i, n, max = 0;
  vector<int> Max;
  vector<DATA> data;

  while(cin >> n)
    PushWordCount(n, data);

  for(i=0; i<data.size(); ++i){
    if(data[i].count == max){
      Max.push_back(data[i].number);
    }else if(data[i].count > max){
      Max.clear();
      Max.push_back(data[i].number);
      max = data[i].count;
    }
  }
  sort(Max.begin(), Max.end());

  for(i=0; i<Max.size(); ++i)
    cout << Max[i] << endl;

  return 0;
}

void PushWordCount(int n, vector<DATA>& data){
  int isFound = 0;
  DATA newdata;
  vector<DATA>::iterator iter = data.begin();

  while(iter != data.end()){
    if(iter->number == n){
      isFound = 1;
      ++iter->count;
      break;
    }
    ++iter;
  }
  if(isFound == 0){
    newdata.number = n;
    newdata.count = 1;
    data.push_back(newdata);
  }
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
	int a[6],t,i,n,j;
	while(scanf("%d",&a[0])!=EOF&&a[0])
{for(i=1;i<3;i++)
scanf("%d",&a[i]);
n=3;
for(i=0;i<n-1;i++)
{
	 for(j=0;j<n-1-i;j++)
	  {
	  	if(a[j]>a[j+1])
	  	 {
	  	 	t=a[j];
	  	 	a[j]=a[j+1];
	  	 	a[j+1]=t;
		   }
	  }
}
 printf("%d\n",a[2]-a[0])	;
}
}

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

char a[510][510];

int main(){
  rep(i,2) rep(j,3) cin >> a[i][j];
  bool ok = true;
  rep(j,3) if(a[1][j] != a[0][2-j]) ok = false;
  cout << (ok ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define inf 1<<29
using namespace std;
 
int Station[301][301];
pair<int,int> p[20];
int dp[(1<<18)][18];
 
void init(){
  for(int i=0;i<(1<<17);i++)for(int j=0;j<17;j++)dp[i][j]=inf;
   
  for(int i=0;i<301;i++){
    for(int j=0;j<301;j++){
      if(i==j)Station[i][j]=0;
      else Station[i][j]=inf;
    }
  }
}
 
int main()
{
  int n,m,l,s,t,a,b,c,x,y;
 
  while(1){
    cin>>n>>m>>l>>s>>t;
    if(n+m+l+s+t==0)break;
    s--;
    init();
    for(int i=0;i<m;i++){
      cin>>a>>b>>c;
      a--;b--;
      Station[a][b]=c;
      Station[b][a]=c;
    }
    for(int i=0;i<l;i++){
      cin>>p[i].f>>p[i].s;
      p[i].f--;
    }
 
    for(int k=0;k<n;k++){
      for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      Station[i][j]=min(Station[i][j],Station[i][k]+Station[k][j]);
    }
      }
    }
 
    dp[0][0]=0;
    for(int i=0;i<l;i++)dp[(1<<i)][i]=Station[s][p[i].f]+p[i].s;
 
    for(int i=1;i<(1<<l);i++){
      for(int j=0;j<l;j++){
    if((i>>j)%2==1){
      for(int k=0;k<l;k++){
        if((i>>k)%2==0){
          dp[(i|(1<<k))][k]=min(dp[(i|(1<<k))][k],
                               dp[i][j]+Station[p[j].f][p[k].f]+p[k].s);
        }
      }
    }
      }
    }
    int ans=0;
    for(int i=1;i<(1<<l)+1;i++){
      for(int j=0;j<l;j++){
    //cout<<dp[i][j]<<" "<<Station[p[j].f][s]<<" "<<i<<" "<<p[j].f<<endl;;
    if((dp[i][j]+Station[p[j].f][s])<=t){
      int sum=0;
      for(int k=0;k<l;k++)if((i>>k)%2==1)sum++;
      ans=max(ans,sum);
    }
      }
    }
    cout<<ans<<endl;;
  }    
  return 0;
}


Measured memory_bytes: 12576
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        int r0=0;
        int r1=0;
        for(int i=0;i<S.length();i++){
            if(i%2==0){
                if(S.charAt(i)!='0')r0++;
            } else {
                if(S.charAt(i)=='0')r0++;
            }
        }

        for(int i=0;i<S.length();i++){
            if(i%2==0){
                if(S.charAt(i)!='1')r1++;
            } else {
                if(S.charAt(i)=='1')r1++;
            }
        }

        System.out.println(Math.min(r0, r1));
    }
}

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,a) for(int i=0;i<(a);i++)
#define MOD 1000000007

int main(){
  ll N,M; cin>>N>>M;
  if(N==1){
    if(M==1) cout<<1<<endl;
    else if(M==2) cout<<0<<endl;
    else cout<<M-2<<endl;
  }else if(N==2){
    cout<<0<<endl;
  }else{
    if(M==1) cout<<N-2<<endl;
    else if(M==2) cout<<0<<endl;
    else cout<<(N-2)*(M-2)<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A[3]={0},a;
    cin>>A[0]>>A[1]>>A[2];
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            if(A[j+1]<A[j]){
                a=A[j];
                A[j]=A[j+1];
                A[j+1]=a;
            }
        }
    }
    cout<<A[1]-A[0]+A[2]-A[1]<<endl;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline

    L, R = map(int, input().split())
    N = R.bit_length()
    mod = 1000000007

    dp = [[[0] * 2 for _ in range(4)] for _ in range(N+1)]
    dp[0][0][0] = 1
    for i in range(N):
        l = L>>(N-i-1)&1
        r = R>>(N-i-1)&1

        # 0 0
        for j in range(2):
            dp[i+1][0][j] = (dp[i+1][0][j] + dp[i][0][j] * int(l == r == 0))%mod
            dp[i+1][1][j] = (dp[i+1][1][j] + dp[i][0][j] * int(r==1 and l==0) + dp[i][1][j] * int(l==0))%mod
            dp[i+1][2][j] = (dp[i+1][2][j] + dp[i][2][j] * int(r==0))%mod
            dp[i+1][3][j] = (dp[i+1][3][j] + dp[i][2][j] * int(r==1) + dp[i][3][j])
        # 0 1
        dp[i+1][0][1] = (dp[i+1][0][1] + dp[i][0][1] * int(l==0 and r==1))%mod
        dp[i+1][1][1] = (dp[i+1][1][1] + dp[i][1][1] * int(l==0))%mod
        dp[i+1][2][1] = (dp[i+1][2][1] + dp[i][2][1] * int(r==1))%mod
        dp[i+1][3][1] = (dp[i+1][3][1] + dp[i][3][1])%mod
        # 1 1
        dp[i+1][0][1] = (dp[i+1][0][1] + sum(dp[i][0]) * int(l==r==1))%mod
        dp[i+1][1][1] = (dp[i+1][1][1] + sum(dp[i][1]) * int(l==1))%mod
        dp[i+1][2][1] = (dp[i+1][2][1] + sum(dp[i][0]) * int(r==1 and l==0) + sum(dp[i][2] * int(r==1)))%mod
        dp[i+1][3][1] = (dp[i+1][3][1] + sum(dp[i][1]) * int(l==0) + sum(dp[i][3]))

    ans = 0
    for j in range(4):
        ans += dp[-1][j][1]
    print(ans%mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

int main(){
    
    ll a,b;
    cin >> a >> b;
    rep(i,1,1010){
        if(floor(i * 0.08) == a && floor(i*0.1) == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define MAXN 20
using namespace std;

bool solve(int arr[], int n, int i, int m)
{
	//m==0就是减完了，也就是数组里存在组合之和等于m 
	if (m == 0)
		return true;
	//到达数组末尾不能使得m==0，也就是不存在 
	if (i >= n)
		return false;
		
	return solve(arr, n, i+1, m) || solve(arr, n, i+1, m-arr[i]);
} 

int main(void)
{
	int arr[MAXN];
	int n, q;
	int M;
		
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> M;
		if (solve(arr, n, 0, M) == true) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}
	
	
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int k;
  string s;
  cin >> k >> s;
  if(s.size() <= k) {
    cout << s;
  } else {
    rep(i, 0, k) {
      cout << s[i];
    }
    cout << "...";
  }
}

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

using namespace std;
using ll = long long;

int main(){
	int n;
	cin >> n;
	vector<vector<int> > a(22, vector<int>(n));
	for(int i = 0; i < n; ++ i){
		int x;
		cin >> x;
		for(int k = 0; k < 22; ++ k) a[k][i] = ((x >> k) & 1);
	}
	for(int i = 1; i < n; ++ i){
		for(int k = 0; k < 22; ++ k) a[k][i] += a[k][i - 1];
	}
	ll ans = 0;
	for(int i = 0; i < n; ++ i){
		int curr = n - 1;
		for(int k = 0; k < 22; ++ k){
			int l = i, r = n - 1;
			while(l < r){
				int mid = (l + r + 1) / 2;
				if(a[k][mid] - (i ? a[k][i - 1] : 0) < 2) l = mid;
				else r = mid - 1;
			}
			curr = min(curr, l);
		}
		ans += curr - i + 1;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 18304
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

signed main() {
    int r, c;
    cin >> r >> c;
    vector<vector<char>> grid(r, vector<char>(c));
    REP(i, r) {
        REP(j, c) { cin >> grid[i][j]; }
    }
    int ultimatechampion = 0;
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            if (grid[i][j] == '#') {
                continue;
            }
            vector<vector<bool>> visited(r, vector<bool>(c));
            vector<vector<int>> dist(r, vector<int>(c));
            int maxx = 0;
            visited[i][j] = true;
            queue<pair<int, int>> q;
            q.push({i, j});
            while (!q.empty()) {
                pair<int, int> s = q.front();
                q.pop();
                int cur_x = s.first;
                int cur_y = s.second;
                vector<int> dx = {1, 0, -1, 0};
                vector<int> dy = {0, 1, 0, -1};
                for (int i = 0; i < 4; i++) {
                    int next_x = cur_x + dx[i];
                    int next_y = cur_y + dy[i];
                    if (next_x >= r || next_x < 0 || next_y >= c || next_y < 0) {
                        continue;
                    }
                    if (grid[next_x][next_y] == '#') {
                        continue;
                    }
                    if (visited[next_x][next_y] == true) {
                        continue;
                    }
                    dist[next_x][next_y] = dist[cur_x][cur_y] + 1;
                    visited[next_x][next_y] = true;
                    q.push({next_x, next_y});
                    if (dist[next_x][next_y] > maxx) {
                        maxx = dist[next_x][next_y];
                    }
                }
            }
            if (maxx > ultimatechampion) {
                ultimatechampion = maxx;
            }
        }
    }
    cout << ultimatechampion << endl;
}

Measured memory_bytes: 256
/*  */
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
#include <cassert>
#include <functional>
#include <iterator>
#include <iomanip>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,1024000")

#define sti				set<int>
#define stpii			set<pair<int, int> >
#define mpii			map<int,int>
#define vi				vector<int>
#define pii				pair<int,int>
#define vpii			vector<pair<int,int> >
#define rep(i, a, n) 	for (int i=a;i<n;++i)
#define per(i, a, n) 	for (int i=n-1;i>=a;--i)
#define clr				clear
#define pb 				push_back
#define mp 				make_pair
#define fir				first
#define sec				second
#define all(x) 			(x).begin(),(x).end()
#define SZ(x) 			((int)(x).size())
#define lson			l, mid, rt<<1
#define rson			mid+1, r, rt<<1|1
#define getBits(x)		__builtin_popcount(x)
#define getBitIdx(x)	__builtin_ffs(x)

typedef long long LL;
const int maxn = 1e5+5;
int a[maxn];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// #ifndef ONLINE_JUDGE
		// freopen("data.in", "r", stdin);
		// freopen("data.out", "w", stdout);
	// #endif
	
	int n, x;
	map<int,int> tb;
	
	scanf("%d", &n);
	rep(i, 0, n) {
		scanf("%d", a+i);
	}
	sort(a, a+n);
	
	int i = 0;
	int n2 = 0, n1 = 0;
	
	while (i < n) {
		int j = i++;
		while (i<n && a[j]==a[i]) ++i;
		int c = i - j;
		if (c & 1)
			++n1;
		else
			++n2;
	}
	
	int ans;
	if (n2 & 1) {
		ans = (n2 - 1) + n1;
	} else {
		ans = n2 + n1;
	}
	
	printf("%d\n", ans);
	
	// #ifndef ONLINE_JUDGE
		// printf("time = %ldms.\n", clock());
	// #endif
	
	return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-6;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void ckmin(T& a, T b) { a = min(a, b); }
template <class T> void ckmax(T& a, T b) { a = max(a, b); }

// (Integer/Long).bitCount(x)
int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << h; if (sizeof...(t)) cerr << ", "; DBG(t...); }

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
}

// Binary Exponentiation
ll pow(ll b, ll e, ll m = 0LL, ll ans = 1LL) { while (e) { if (e & 1LL) { ans *= b; if (m) ans %= m; } b *= b, e >>= 1LL; if (m) b %= m; } return ans; }



void solve(int tcn) {
	int a; cin >> a;
	cout << a + a * a + a * a * a << nl;
}

int main() {
    setIO();

    int t = 1; //cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve(i);
	}
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
long long ans=0;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;char ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
int main(){
	long long n=read();
	ans=(n)*(n-1)/(long long)2;
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
import math
n = int(input())
#n = 9876543210

def f(a,b):
  aa = len(str(a))
  bb = len(str(b))
  return max(aa,bb)

ans = 0
nn = int(math.sqrt(n))
for i in range(nn+1,0,-1):
  if(n%i == 0):
    x = f(i,int(n/i))
    ans = x
    break
print(ans)
    

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

int main(){
	string s;
	cin>>s;
	
	map<char,int> mp;
	for(int i=0;i<26;i++){
		mp['a'+i]=0;
	}
	
	for(int i=0;i<s.size();i++){
		mp[s[i]]++;
	}
	
	for(int i=0;i<26;i++){
		if(mp['a'+i]==0){
			char a='a'+i;
			cout<<a<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
	return 0;
}

Measured memory_bytes: 512
M = 10**9+7

def factorial(n):
    f = 1
    for i in range(1,n+1):
        f = f*i%M
    return f

def comb(n,k):
    if n==0 or k == 0:
        return 1
    if n<k:
        return 0

    return perm(n,k)*inverse(factorial(k))%M

def mcomb(n,k):
    return comb(n+k-1,k)

def perm(n,k):
    if n==0 or k == 0:
        return 1
    if n<k:
        return 0

    p = 1
    for i in range(n-k+1,n+1):
        p = p*i%M

    return p

def inverse(a):
    return pow(a,M-2,M)
  
n,k = tuple(map(int,input().split()))

for i in range(k):
  i += 1
  t = comb(k-1,i-1)
  u = comb(n-k+1,i)
  ans = t*u
  ans %= M
  print(ans)

Measured memory_bytes: 3316
from heapq import heappush, heappop
import sys
input = sys.stdin.readline

def dijkstra(edges, size, source):
    distance = [float('inf')] * size
    distance[source] = 0
    visited = [False] * size
    pq = []
    heappush(pq, (0, source))
    while pq:
        dist_v, v = heappop(pq)
        visited[v] = True
        for u, weight in edges[v]:
            if not visited[u]:
                new_dist = dist_v + weight
                if distance[u] > new_dist:
                    distance[u] = new_dist
                    heappush(pq, (new_dist, u))
    return distance

n, m, s, t = map(int, input().split())
G_y = [[] for _ in range(n+1)]
G_s = [[] for _ in range(n+1)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    G_y[u].append((v, a))
    G_y[v].append((u, a))
    G_s[u].append((v, b))
    G_s[v].append((u, b))
dist_y = dijkstra(G_y, n+1, s)
dist_s = dijkstra(G_s, n+1, t)
ans = [0] * n
prev = 0
for i in range(1, n+1)[::-1]:
    amount = 10**15 - (dist_y[i] + dist_s[i])
    prev = max(prev, amount)
    ans[i-1] = prev
print(*ans, sep='\n')

Measured memory_bytes: 116064
# coding: utf-8
# Your code here!
n = int(input())
string = str(1)
for i in range(2,n + 1):
    string += str(i)

x = []    
import itertools
for i in itertools.permutations(string):
    x.append(i)
    
a = tuple(input().split(" "))
b = tuple(input().split(" "))

for i,j in enumerate(x):
    if a == j:
        a_res = i + 1
    if b == j:
        b_res = i + 1

print(abs(a_res - b_res))

Measured memory_bytes: 7924
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    cin >> x;
    while(x)
    {
        int m = x % 10;
        x /= 10;
        if(m == 9)
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;

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

int main() {

	Int a, b, c, d;
	cin >> a >> b >> c >> d;

	Int temp_c = 0;
	Int temp_d = 0;
	Int temp_cd = 0;
	Int cd = c*d/gcd(c, d);

	//1-B
	temp_c = b / c;
	temp_d = b / d;
	temp_cd = b / cd;

	//A-B
	temp_c -= (a - 1) / c;
	temp_d -= (a - 1) / d;
	temp_cd -= (a - 1) / cd;

	Int ans = (b - a + 1) - temp_c - temp_d + temp_cd;

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  int n=S.size();
  int k;cin>>k;
  for(int i=0;i<n;i++){
    if(S[i]=='a') continue;
    if('z'-S[i]+1<=k){
      k-='z'-S[i]+1;
      S[i]='a';
    }
  }
  if(k>0){
    k%=26;
    S[n-1]+=k;
  }
  cout<<S<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
using namespace std; 
/* DSU */ 
ll parent[100005];
ll rankr[100005];
ll find_set(ll v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void make_set(ll v) {
    parent[v] = v;
    rankr[v] = 0;
}
void union_sets(ll a, ll b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rankr[a] < rankr[b])
            swap(a, b);
        parent[b] = a;
        if (rankr[a] == rankr[b])
            rankr[a]++;
    }
}

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
 
ll mod(ll a, ll b) {return (a % b + b) % b;}
 
ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
 

int main()
{
	fast;
	ll n,m; cin>>n>>m;
	for(ll i = 1; i <= n; i++)
	{
		make_set(i);
	}
	ll arr[n+1]; for(ll i = 1; i <= n; i++) cin>>arr[i];
	while(m--)
	{
		ll a,b; cin>>a>>b;
		union_sets(a,b);
	}
	ll ans = 0;
	for(ll i = 1; i <= n; i++)
	{
		if(arr[i] == i)
			ans++;
		else
		{
			ll a = find_set(i); ll b = find_set(arr[i]);
			if(a == b)
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5960
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)

int main() {
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    ll mod = 1000000007;
    if (n+1>k) rep2(i, k, n+2){
        ans += (i*(n-i+1)%mod+1)%mod;
        ans %= mod;
    }
    else ans = 1;
    cout << ans << endl;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define REP(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 int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;
bool dpx[3000][16001] = {};
bool dpy[3000][16001] = {};

int main() {
  string s;
  cin >> s;
  int x, y;
  cin >> x >> y;
  x += 8000;
  y += 8000;

  vector<int> xl, yl;

  int init = 0;
  REP(i, s.length()) {
    if (s[i] == 'T') {
      break;
    }
    init++;
  }
  // 1: yを積む、-1:xを積む
  int state = 1;
  int c = 0;
  FOR(i, init + 1, s.length()) {
    if (s[i] == 'F') {
      c++;
    } else {
      if (c != 0) {
        if (state == 1)
          yl.push_back(c);
        else
          xl.push_back(c);
        c = 0;
      }
      state *= -1;
    }
  }
  if (c != 0) {
    if (state == 1)
      yl.push_back(c);
    else
      xl.push_back(c);
  }

  dpx[0][8000 + init] = true;
  dpy[0][8000] = true;

  FOR(i, 1, xl.size() + 1) {
    REP(j, 16001) {
      if (0 <= j + xl[i - 1] && j + xl[i - 1] <= 16000) {
        dpx[i][j] = dpx[i][j] || dpx[i - 1][j + xl[i - 1]];
      }
      if (0 <= j - xl[i - 1] && j - xl[i - 1] <= 16000) {
        dpx[i][j] = dpx[i][j] || dpx[i - 1][j - xl[i - 1]];
      }
    }
  }

  FOR(i, 1, yl.size() + 1) {
    REP(j, 16001) {
      if (0 <= j + yl[i - 1] && j + yl[i - 1] <= 16000) {
        dpy[i][j] = dpy[i][j] || dpy[i - 1][j + yl[i - 1]];
      }
      if (0 <= j - yl[i - 1] && j - yl[i - 1] <= 16000) {
        dpy[i][j] = dpy[i][j] || dpy[i - 1][j - yl[i - 1]];
      }
    }
  }

  if (dpx[xl.size()][x] && dpy[yl.size()][y]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 67840
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N = z()
AC, WA, TLE, RE = 0, 0, 0, 0
for i in range(N):
    tmp = S()
    tmp = tmp[:-1]
    if(tmp == 'AC'):
        AC += 1
    elif (tmp == 'WA'):
        WA += 1
    elif (tmp == 'TLE'):
        TLE += 1
    elif (tmp == 'RE'):
        RE += 1

print('AC x', AC)
print('WA x', WA)
print('TLE x', TLE)
print('RE x', RE)


Measured memory_bytes: 27128
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);
int dp[212121];

int main() {
	int N, K, C;
	scanf("%d%d%d", &N, &K, &C);
	string s;
	cin >> s;
	if (s[N - 1] == 'o') dp[N - 1] = 1;
	for (int i = N - 2; i >= 0; i--) {
		if (s[i] == 'o') {
			dp[i] = 1;
			if (i + C + 1 < N) dp[i] += dp[i + C + 1];
		} else {
			if (i + 1 < N) dp[i] = dp[i + 1];
		}
	}
	int akhir = -1e9;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int tmp = cnt;
		if (akhir + C + 1 < N) {
			int xx = akhir + C + 1;
			if (xx > i) {
				tmp += dp[xx];
			} else {
				if (i + 1 < N) tmp += dp[i + 1];
			}
		}
		if (tmp < K && s[i] == 'o') printf("%d\n", i + 1);
		if (i - akhir - 1 >= C && s[i] == 'o') {
			cnt++;
			akhir = i;
		}
	}
}

Measured memory_bytes: 2564
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7;
const int INF=1<<30;
const int MAX_N=100003;

int main(){
  ll X,Y;
  cin >> X >> Y ;
  if(abs(X-Y)<=1)  cout << "Brown" << endl;
  else cout << "Alice" << endl;
  return 0;
}

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

using namespace std;

#define int long long
#define PB push_back
typedef pair<int, int> pii;
static const int INF = 1LL<<61;

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

  int n, ans = 0;
  string s;
  cin >> n >> s;

  for (int i = 0; i < n; ++i) {
    string t;
    cin >> t;
    for (int j = 0; j <= t.size() - s.size(); ++j) {
        if (s[0] != t[j]) continue;

        for (int k = 0; j + (s.size() - 1) * (k + 1) < t.size(); ++k) {
            bool flg = true;
            for (int i2 = 0; i2 < s.size(); ++i2) {
                if (s[i2] == t[j + i2 * (k + 1)]) continue;
                flg = false;
                break;
            }

            if (flg) {
                ans++;
                goto end;
            }
        }
    }

    end:;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
struct edge{
    ll from; ll to; ll cost;
};
//vec<edge> edges;
vvec<int> to,ot;
int ok[2505];
int ko[2505];
bool OK[2505];
ll d[2505];
void dfs(int v, int p){
    if(ok[v] > 0)return;
    ok[v]++;
    for(auto nv: to[v]){
        if(nv == p)continue;
        dfs(nv, v);
    }
}
void sfd(int v, int p){
    if(ko[v] > 0)return;
    ko[v]++;
    for(auto nv: ot[v]){
        if(nv == p)continue;
        sfd(nv, v);
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N,M,P;
    cin >> N >> M >> P;
    vector<tuple<int, int, int>> edges;
    to.resize(N);ot.resize(N);
    rep(i, M){
        ll a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        c -= P;
        c *= -1;
        //edges.push_back({a,b,c});
        edges.emplace_back(a,b,c);
        to[a].push_back(b);
        ot[b].push_back(a);
    }
    rep(i,N)ok[i] = ko[i] = 0;
    dfs(0,-1);
    sfd(N-1,-1);
    rep(i,N){
        if(ok[i] > 0 && ko[i] > 0)OK[i] = true;
    }
    //bellman ford
    rep(i,N){
        d[i] = INF;
    }
    d[0] = 0;
    //O(NM)
    int step = 0;
    bool updated = true;
    while(updated){
        //all edges
        updated = false;
        rep(i,M){
            int a,b,c;
            tie(a,b,c) = edges[i];
            if(!OK[a])continue;
            if(!OK[b])continue;
            int newD = d[a] + c;
            if(newD < d[b]){
                updated = true;
                d[b] = newD;
            }
            /*
            edge e = edges[i];
            if(!OK[e.from])continue;
            if(!OK[e.to])continue;
            if(d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                updated = true;
            }*/
        }
        step++;
        if(step > N){
            cout << -1 << endl;
            return 0;
        }
    }
    /*
    rep(i,N)cerr<<ok[i]<<" ";
    cerr<<endl;
    rep(i,N)cerr<<ko[i]<<" ";
    cerr<<endl;
    rep(i,N)cerr<<d[i] <<" ";
    cerr << endl;
    */
    ll ans = -d[N-1];
    ans = max(ans, 0LL);
    cout << ans << endl;
}

Measured memory_bytes: 768
#include<stdio.h>
int main()
{
	int n,k,a[100],i,x,f;
	while(scanf("%d%d",&n,&k),n)
	{
		for(i=0;i<k;++i)scanf("%d",&a[i]);
		while(n--)for(i=0;i<k;++i)scanf("%d",&x),a[i]-=x;
		for(f=i=0;i<k;++i)if(a[i]<0)f=1;
		puts(f?"No":"Yes");
	}
	return 0;
}

Measured memory_bytes: 736
#[allow(unused_imports)]
use proconio::marker::*;
use proconio::*;

macro_rules! echo {
    ($ x : expr ) => {
        println!("{}", $x);
    };
}

macro_rules! YesNo {
    ($ flag : expr ) => {
        if $flag {
            "Yes"
        } else {
            "No"
        }
    };
}

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: String,
    };
    echo!(YesNo!(N.contains("7")));
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=3e3+10;
string A,B;
ll N,M;
ll dp[MAX][MAX];
int solve(int i,int j)
{
    if(i>=N||j>=M)return 0;
    if(dp[i][j]!=-1)return dp[i][j];
    int ans=0;
    if(A[i]==B[j]){
        ans =  1+solve(i+1,j+1);
    }
    else{
        ans = max(solve(i+1,j),solve(i,j+1));
    }
    return dp[i][j]=ans;
}
void path(int i,int j)
{
    if(i>=N||j>=M)return;
    if(A[i]==B[j]){
        cout<<A[i];
        path(i+1,j+1);
    }
    else{
        if(solve(i+1,j)==dp[i][j]){
            path(i+1,j);
        }
        else if(solve(i,j+1)==dp[i][j]){
            path(i,j+1);
        }
    }
}
int main ()
{
    memset(dp,-1,sizeof dp);
    cin >> A >> B;
    N = A.size();
    M = B.size();
    solve(0,0);
    path(0,0);
    return 0;
}





Measured memory_bytes: 71424
#include<bits/stdc++.h>
#include<stdio.h> //per fare input output con scanf and printf
#include<stdlib.h> //per fare qsort e bsearch
#include<string.h> // per fare strcpy(sarrivo, spartenza) strcat(str, aggiungo) strcmp(a,b) che da 0 se sono uguali
#include<math.h>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<map>
 
using namespace std;
 
#define ld long double
#define ll long long int
#define vi vector <ll> 
#define pi pair <int, int>
#define binary(v, el) binary_search((v).begin(), (v).end(), (el))
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(n, t) get<(n)>((t)) // get element of a tuple
#define F first
#define S second
#define input(type, n) type n; cin >> n
#define FORN(n) for (ll i=0;i<(n); i++)
#define print(x) cout << x << endl
#include <iomanip>      // std::setprecision
#define M 1000*1000*1000+7
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


int main(){
  IOS
  ll n;cin>>n;
  vi v;
  for (ll i=0;i<n;i++){
    ll temp; cin>>temp;v.PB(temp);
  }
  v[0]--;
  for (ll i=1;i<n;i++){
    if (v[i]==v[i-1]);
    else v[i]--;
  }
  ll flag = 1;
  for (ll i=1;i<n;i++){
    if (v[i]>=v[i-1]);
    else flag = 0;
  }
  if (flag) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 1400
#include<stdio.h>

int main(void)
{
	int a[2];
	int k=0, i;

	scanf("%d", &a[0]); 
	scanf("%d", &a[1]);

	for(i=0; i<2; i++){
		if(a[0]>a[1]){
			k+=a[0]; a[0]-=1;
		} else if(a[0]<a[1]){
			k+=a[1]; a[1]-=1;
		}else {
			k+=a[0]; a[0]-=1;
		}
	}

	printf("%d", k);
	
	return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		System.out.println(solve(b,c,d)-solve(a-1,c,d));

	}
	static long gcd(long a,long b) {
		if(b==0) {
			return a;
		}
		return gcd(b,a%b);
	}
	static long solve(long b,long c,long d) {
		long ret = b;
		long other = c*d/gcd(c,d);
		ret-= b/c;
		ret -= b/d;
		ret += b/other;
		return ret;
	}

}


Measured memory_bytes: 22612
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;

const int N = 1e5 + 500;

int n, l, bst, a[N];

int main(){
	scanf("%d%d", &n, &l);
	for(int i = 0;i < n;i++){
		scanf("%d", a + i);
		if(i && a[i] + a[i - 1] >= l)
			bst = i;
	}
	if(!bst){
		printf("Impossible\n");
		return 0;
	}
	printf("Possible\n");
	for(int i = 1;i < bst;i++)
		printf("%d\n", i);
	for(int i = n - 1;i > bst;i--)
		printf("%d\n", i);
	printf("%d\n", bst);
	
}	

Measured memory_bytes: 1152
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

int n, m, lub[33];

int main() {
  init_ios();
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    int p, q;
    cin >> p;
    while (p--) {
      cin >> q;
      ++lub[q];
    }
  }
  int res = 0;
  for (int i = 1; i <= m; ++i)
    if (lub[i] == n)
      ++res;
  cout<<res<<"\n";
}

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

int main() {
	int week;
	cin >> week;
	int debt = 100000;
	while (week--)
	{
		debt = debt * 1.05;
		int rem = debt % 1000;
		if (rem > 0) {
			debt += (1000 - rem);
		}

	}
	cout << debt << endl;

	return 0;
}

Measured memory_bytes: 3068
#include<iostream>
#include<fstream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fast ios_base::sync_with_stdio(false),cin.tie(nullptr)
int main()
{
        ll n,q;
        cin>>n;
        ll cnt[100001]={0},sum=0;
        for(int i=0;i<n;i++)
        {
                int x;
                cin>>x;
                sum+=x;
                cnt[x]++;

        }
        cin>>q;
        for(int i=0;i<q;i++)
        {
                int b,c;
                cin>>b>>c;
                if(cnt[b]>0)
                {
                        sum-=cnt[b]*b;
                        sum+=cnt[b]*c;
                        cnt[c]+=cnt[b];

                        cnt[b]=0;


                }
                cout<<sum<<endl;
        }

}


Measured memory_bytes: 4412