akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author kessido
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        C755 solver = new C755();
        solver.solve(1, in, out);
        out.close();
    }

    static class C755 {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.NextInt();
            long x = 357;
            int res = 0;
            while (x <= n) {
                if (isOk(x)) {
                    res++;
                }
                x = next(x);
            }
            out.println(res);
        }

        private long next(long x) {
            long divide = 1;
            while (true) {
                long cur = (x / divide) % 10;
                if (cur != 7) {
                    if (cur != 0) {
                        x += 2 * divide;
                    } else {
                        x += 3 * divide;
                    }
                    return x;
                } else {
                    x -= 4 * divide;
                }
                divide *= 10;
            }
        }

        private boolean isOk(long x) {
            return has(x, 3) && has(x, 5) && has(x, 7);
        }

        private boolean has(long x, int i) {
            while (x != 0) {
                if (x % 10 == i) return true;
                x /= 10;
            }
            return false;
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine(), " \t\n\r\f,");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int NextInt() {
            return Integer.parseInt(next());
        }

    }

    static class OutputWriter extends PrintWriter {
        public OutputWriter(Writer out) {
            super(out);
        }

        public OutputWriter(File file) throws FileNotFoundException {
            super(file);
        }

        public OutputWriter(OutputStream out) {
            super(out);
        }

    }
}



Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
const int M = 1000005;
void solve() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];	
	}
	vector<int> cnt(M);
	for (int x : a) {
		if (cnt[x] != 0) {
			cnt[x] = 2;
			continue;
		}
		for (int i = x; i < M; i += x) cnt[i]++;
	}
	int ans = 0;
	for (int x : a) {
		if (cnt[x] == 1) ans++;
	}
	cout << ans << endl;
	return;
}
int main() {
	solve();
	return 0;
}

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

int main()
{
	const long long int TH = 1000000000000000000LL;
	int n;
	cin >> n;
	long long int ans = 1;
	for(int i = 0; i < n; ++i){
		long long int a;
		cin >> a;
		if(a == 0) ans = 0;
		if(ans > 0){
			if(TH / ans < a){
				ans = -1;
			}else{
				ans *= a;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]


a,b = map(int, input().split())

print( (a+b)%24 )


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

int main(){
  int n;
  cin>>n;
  int no = n%10;
  switch(no){
    case 1:
          cout<<"pon";
   		  break;
    case 0:
    	  cout<<"pon";
   		  break;
     case 6:
    	  cout<<"pon";
   		  break;
     case 8:
    	  cout<<"pon";
   		  break;
     case 3:
    	  cout<<"bon";
   		  break;
     case 2:
    	  cout<<"hon";
   		  break;
     case 4:
    	  cout<<"hon";
   		  break;
     case 5:
    	  cout<<"hon";
   		  break;
     case 7:
    	  cout<<"hon";
   		  break;
     case 9:
    	  cout<<"hon";
   		  break;
  }
}


Measured memory_bytes: 3616
#include <iostream>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  int D, T, S;
  cin >> D >> T >> S;
  bool ans = S * T >= D;
  cout << ((ans) ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int N;
	int a[52],b[52];
	
	scanf("%d",&N);
	rep(i,N)scanf("%d",&a[i]);
	rep(i,N)scanf("%d",&b[i]);
	//for(int i = 0 ; i < N ; i ++)scanf("%d%d",&a[i],&b[i]);
	
	ll ret = 0;
	ll MAX = 52;
	while(1){
		ll dist[52][52] = {};
		rep(i,52)rep(j,52){
			if(i == j)dist[i][j] = 0;
			else dist[i][j] = 1;
		}
		for(int i = 1 ; i < 52 ; i ++){
			if((ret>>i)&1LL){
				for(int j = 0 ; j < 52 ; j ++){
					dist[j][j%i] = 0;
				}
			}
		}
		rep(k,52)rep(i,52)rep(j,52)dist[i][j] = min( dist[i][j] , dist[i][k]+dist[k][j] );
		bool t = true;
		rep(i,N){ if(dist[a[i]][b[i]] != 0){ t = false; break; } }
		if(t)break;
		for(int i = 1 ; i < MAX ; i ++){
			for(int j = 0 ; j < 52 ; j ++){
				dist[j][j%i] = 0;
			}
			rep(z,52)rep(x,52)rep(y,52)dist[x][y] = min ( dist[x][y] , dist[x][z]+dist[z][y] );
			bool t = true;
			rep(j,N){ if(dist[a[j]][b[j]] != 0){ t = false; break; } }
			if(t){
				//cout << i << endl;
				MAX = i;
				ret += 1LL<<i;
				break;
			}
			if(i == MAX-1){
				puts("-1");
				return 0;
			}
		}
	}
	cout << ret << endl;
}
		



Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        if(i%3==0){
            printf(" %d",i);
        }
        else if(i/10==3){
            printf(" %d",i);
        }
        else if(i/10==3){
            printf(" %d",i);
        }
        else if(i/100==3){
            printf(" %d",i);
        }
        else if(i/10%10==3){
            printf(" %d",i);
        }
        else if(i/100%10==3){
            printf(" %d",i);
        }
        else if(i/1000%10==3){
            printf(" %d",i);
        }
        else if(i%10==3){
            printf(" %d",i);
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    R = float(sys.stdin.readline().rstrip())
    G = float(sys.stdin.readline().rstrip())
    print(int(R+(G-R)*2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <cstdlib>
#include <vector>

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

// constant values
const int MAX_NUM = 100010;
const int NUM_SEL = 3;

// DP table and initilization of it
long long dp[MAX_NUM][NUM_SEL];

int main()
{
  // input
  int N;
  std::cin >> N;
  long long a[MAX_NUM][NUM_SEL];
  for ( int i = 0; i < N; i++ ) {
    for ( int j = 0; j < NUM_SEL; j++ ) {
      std::cin >> a[i][j];
    }
  }

  for ( int i = 0; i < N; i++ ) {
    for ( int j = 0; j < NUM_SEL; j++) {
      for ( int k = 0; k < NUM_SEL; k++ ) {
        if ( j == k ) continue;
        chmax(dp[i+1][k], dp[i][j] + a[i][k]);
      }
    }
  }

  long long res = 0;
  for ( int i = 0; i < NUM_SEL; i++ ) {
    chmax(res, dp[N][i]);
  }
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string str;
    cin >> str;
    while(true){
        str.erase(str.size() - 1, 1);
        if(str.substr(0, str.size() / 2) == str.substr(str.size() / 2)){
            break;
        }
    }
    cout << str.size() << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    string S; cin >> S;
    vector<int> len;
    int ans = 0;
    int c = 0;
    rep(i, n - 1) {
        if(S[i] == S[i + 1]) ans++;
        else c++;
    }
    cout << ans +  min(c, k *2)  << endl;


    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxk=300010;
int k,dl[maxk<<2],f[maxk],id;
bool vis[maxk];
struct edge
{
    int t,w;
    edge *next;
}*con[maxk];
void ins(int x,int y,int w)
{
    edge *p=new edge;
    p->t=y;
    p->w=w;
    p->next=con[x];
    con[x]=p;
}
void spfa()
{
    int head=1,tail=1;
    memset(f,0x3f,sizeof(f));
    dl[1]=1;vis[1]=1;f[1]=0;
    for(int v=1;head<=tail;vis[v]=0,v=dl[++head])
        for(edge *p=con[v];p;p=p->next)
            if(f[p->t]>f[v]+p->w)
            {
                f[p->t]=f[v]+p->w;
                if(!vis[p->t]) vis[p->t]=1,dl[++tail]=p->t;
            }
}

int main()
{
    scanf("%d",&k);
    for(int i=1;i<=k;i++)
        ins(i,i*10%k,0),ins(i,(i+1)%k,1);
    spfa(); 
    printf("%d",f[0]+1);
}

Measured memory_bytes: 13440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e18;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<ll> a(3*n),sum1(3*n+1,0),sum2(3*n+1,0);
	priority_queue<ll,vector<ll>,greater<ll>> que1;
	priority_queue<ll> que2; 
	rep(i,3*n){
		cin>>a[i];
		if(i<n){
			que1.push(a[i]);
			sum1[i+1]=sum1[i]+a[i];
		}
		if(i>=2*n){
			que2.push(a[i]);
		}
	}
	for(int i=3*n-1;i>=2*n;i--){
		sum2[i]=sum2[i+1]+a[i];
	}
	FOR(i,n,2*n){
		que1.push(a[i]);
		sum1[i+1]=sum1[i]-que1.top()+a[i];
		que1.pop();
	}
	for(int i=2*n-1;i>=n;i--){
		que2.push(a[i]);
		sum2[i]=sum2[i+1]-que2.top()+a[i];
		que2.pop();
	}
	ll ans=-inf;
	for(int i=n;i<=2*n;i++){
		chmax(ans,sum1[i]-sum2[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 9588
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
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); }
// *max_element(all(d))
// priority_queue<int,vector<int>,greater<int>>
int solve(){
  int n;
  cin >> n;
  vector<int>v(n);
  rep(i,n){
    cin >> v[i];
    v[i]--;
  }
  ll ans = 0;
  rep(i,n){
    if(v[v[i]] == i)ans++;
  }
  cout << ans / 2 << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  int i;
  int d=0;
  for(i=0;i<n;i++){
    int l;
    cin >> l;
    d=d+l;
    if(d>x){
      cout << i+1;
      break;
    }
  }
  if(i==n){
    cout << n+1;
  }
  return 0;
}

  


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
int a,c=0,i,j;
scanf("%d",&a);
int b[a];
for(int i=0;i<a;i++){
scanf("%d",&b[i]);
}
for(i=0;i<a;i++){
for(j=0;j<=i;j++){
if(b[i]<b[i-j]){
break;
}
if(j==i)c+=1;
}
}
printf("%d",c);

return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    string a, b;

	cin >> a >> b;

	long c = stol(a + b);
	long sq = sqrt((double)c);

	if (sq * sq == c) Out("Yes");
	else Out("No");
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    int tasu,hiku,kakeru;
    tasu=a+b;hiku=a-b;kakeru=a*b;
    if(tasu>hiku && tasu>kakeru){
        printf("%d",tasu);
    }
    if(hiku>tasu && hiku>kakeru){
        printf("%d",hiku);
    }
    if(kakeru>tasu && kakeru>hiku){
        printf("%d",kakeru);
    }
    if(tasu==hiku || tasu==kakeru){
        printf("%d",tasu);
    }
    return 0;
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class BTripleDots {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int k; string s; cin >> k >> s;
      int n = s.size();
      if (n <= k) {
        cout << s << endl; return;
      }
      rep(i, k) {
        cout << s[i];
      }
      cout << "..." << endl;
    }
};

signed main() {
  BTripleDots solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main(){
    vector<int> v(3);
    for (int i = 0; i < 3; ++i) {
        cin >> v[i];
    }
    int k;
    cin >> k;
    sort(v.begin(), v.end());
    for (int i = 0; i < k; ++i) {
        v[2]*=2;
    }
    cout << v[0] + v[1] + v[2] << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

int solve(int N, vector<int> a, vector<int> b) {
	int ans = N;
	vector<int> ind(3);
	iota(ind.begin(), ind.end(), 0);
	sort(ind.begin(), ind.end(), [&](int i, int j) {
		return b[i] - a[i] < b[j] - a[j];
	});
	{
		vector<int> na(3);
		vector<int> nb(3);
		for (int i = 0; i < 3; i++) {
			na[i] = a[ind[i]];
			nb[i] = b[ind[i]];
		}
		a = na;
		b = nb;
	}
	for (int cf = 0; cf * a[0] <= N; cf++) {
		if (cf > 0 && a[0] > b[0]) break;
		for (int cs = 0; cf * a[0] + cs * a[1] <= N; cs++) {
			if (cs > 0 && a[1] > b[1]) break;
			int ct = (N - cf * a[0] - cs * a[1]) / a[2];
			ans = max(ans, cf * b[0] + cs * b[1] + ct * b[2] + (N - cf * a[0] - cs * a[1] - ct * a[2]));
			ct = 0;
			ans = max(ans, cf * b[0] + cs * b[1] + ct * b[2] + (N - cf * a[0] - cs * a[1] - ct * a[2]));
		}
	}
	return ans;
}

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

	int N;
	cin >> N;
	vector<int> A(3);
	vector<int> B(3);
	for (auto &t : A) {
		cin >> t;
	} 
	for (auto &t : B) {
		cin >> t;
	}
	N = solve(N, A, B);
	N = solve(N, B, A);
	cout << N << '\n';
}

Measured memory_bytes: 3176
import java.io.PrintWriter
import java.util.*

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = next().toInt()
    val A = nextIntList()
    val counter = Counter<Int>()
    A.forEach { a ->
        counter.add(a - 1)
        counter.add(a)
        counter.add(a + 1)
    }
    println(counter.map.values.max())
}

class Counter<T> {
    val map = HashMap<T, Long>()
    fun add(k: T, d: Int = 1) {
        val v = map.getOrPut(k) { 0L }
        map[k] = v + d
    }
}

Measured memory_bytes: 56004
function solve()
    n, k = [parse(Int, x) for x in split(readline())]
    triked = ones(Bool, n)
    for _ in 1:k
        d = parse(Int, readline())
        a = [parse(Int, x) for x in split(readline())]
        for aa in a
            triked[aa] = false
        end
    end
    sum(triked)
end

println(solve())

Measured memory_bytes: 167796
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << std::endl;
}

using namespace std;

int n;

int check(vector<int> &da, int now) {
    deque<Pii> dq;
    stack<Pii> st;
    dq.push_front({0, 0});
    rip(i,n,0) {
        if(dq.back().first < da[i]) {
            dq.push_back({da[i], 1});
        }
        else {
            while(dq.back().first > da[i]) dq.pop_back();
            int look = da[i];
            while(dq.back() == make_pair(look, now)) {
                dq.pop_back(); --look;
            }
            if(dq.back().first == look) {
                auto tmp = dq.back(); dq.pop_back();
                ++tmp.second;
                dq.push_back(tmp);
            }
            else {
                dq.push_back({look, 2});
            }
            if(dq.back().first != da[i]) dq.push_back({da[i], 1});
        }
        if(dq.front().second == 1) return false;
    }
    return true;
}

int main(){
    cin >> n;
    vector<int> da(n);
    rip(i,n,0) cin >> da[i];
    bool ju = true;
    rip(i,n,1) if(da[i] <= da[i-1]) ju = false;
    if(ju) {
        cout << 1 << endl;
        return 0;
    }
    int ng = 1, ok = 300000;
    while(ok-ng > 1) {
        int now = (ok+ng) >> 1;
        if(check(da, now)) ok = now;
        else ng = now;
    }
    cout << ok << endl;
}

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

int a,b,c,d,n;

int main() {

  scanf("%d %d %d %d",&a,&b,&c,&d);
  scanf("%d",&n);
  if(2*a<b) {
    b=2*a;
  }
  if(2*b<c) {
    c=2*b;
  }
  if(2*c<d) {
    d=2*c;
  }
  ll ans=0;
  ans+=(n/2)*1ll*d;
  n%=2;
  ans+=1ll*n*c;
  printf("%lld",ans);

}


Measured memory_bytes: 764
s = input()
k = int(input())
x = 0
substr = set()
while x < k:
    x += 1
    for i in range(len(s) - x + 1):
        if s[i:i+x] not in substr:
            substr.add(s[i:i+x])
substr = list(substr)
substr.sort()
print(substr[k-1])

Measured memory_bytes: 4452
mod=10**9+7
n,m=map(int,input().split())
a=[int(input())for _ in range(m)]
a.append(n+1)
fib=[1,1]
for i in range(n):
	r=fib[-1]+fib[-2]
	fib.append(r%mod)
ans=1
now=0
for x in a:
	ans*=fib[x-1-now]
	if x-1-now<0:
		print(0)
		exit()
	ans%=mod
	now=x+1
print(ans)

Measured memory_bytes: 16804
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var xy = Console.ReadLine().Split().Select(int.Parse).ToArray();
        for (int i = 0; i <= xy[0]; i++)
        {
            if (xy[1] == xy[0] * 2 + (i * 2))
            {
                Console.WriteLine("Yes");
                return;
            }
        }
        Console.WriteLine("No");
    }
}


Measured memory_bytes: 28296
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

int N,K;



signed main()
{
    cin >> N >> K;

    if(K==1)
    {
        cout << 0 << endl;
        return 0;
    }

    if(N/K==1)
    {
        cout << N-K << endl;
    }
    else 
    {
        cout << N-K+1 << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n;
  cin>>n;
  vector<long long> a(n);
  REP(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  long long ans=0,temp=0;
  if(n%2==0){
    REP(i,n/2){
      ans -= 2*a[i];
    }
    ans += a[n/2-1];
    REP(i,n/2){
      ans += 2*a[i+n/2];
    }
    ans -= a[n/2];
  }else{
    REP(i,n/2){
      ans -= 2*a[i];
    }
    REP(i,(n+1)/2){
      if(i<2){
        ans += a[i+n/2];
      }else{
        ans += 2*a[i+n/2];
      }
    }
  }
  if(n%2==0){
    REP(i,n/2){
      temp -= 2*a[i];
    }
    temp += a[n/2-1];
    REP(i,n/2){
      temp += 2*a[i+n/2];
    }
    temp -= a[n/2];
  }else{
    REP(i,(n+1)/2){
      temp -= 2*a[i];
    }
    temp += a[(n+1)/2-1]+a[(n+1)/2-2];
    for(int i=(n+1)/2;i<n;i++){
      temp += 2*a[i];
    }
  }
  
  ans = max(ans,temp);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 ll INF = 1LL<<60;
const ll M = pow(10,9)+7;
/*template*/

ll new_pow(ll a,ll b){
  ll res=1;
  while(b!=0){
    if(b&1)res=res*a%M;
    a=a*a%M;
    b=b>>1;
  }
  return res;
}

ll comb(ll n,ll k){
  if(k>n/2)return comb(n,n-k);
  ll res=1;
  for(ll i=0;i<k;i++){
    res=res*(n-i)%M;
    res=res*new_pow(k-i,M-2)%M;
  }
  return res;
}

ll ans(ll x,ll y){
  if(x>2*y || y>2*x || (x+y)%3!=0)return 0;
  ll n=(x+y)/3;
  ll k=x-n;
  return comb(n,k);
}

int main()
{
  ll x,y;cin>>x>>y;
  cout<<ans(x,y)<<endl;
  return 0;
}


Measured memory_bytes: 256
while True:
    h, w = map(int, input().split())
    if(w == h == 0): break
    for i in range(h):
        for j in range(w):
            if i == 0 or i == h - 1:
                print('#', end = '')
            else:
                if j == 0 or j == w - 1:
                    print('#', end = '')
                else:
                    print('.', end = '')
        print('')
    print('')



Measured memory_bytes: 7008
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

s=SI()
for i in range(len(s)):
    print("x",end="")

Measured memory_bytes: 65808
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
using ll = long long;
using pll = pair<ll,ll>;
using vvll = vector<vector<ll>>;
using vll = vector<ll>;
using vstr = vector<string>;
const ll MOD=1000000007;
vll dx{0,1,0,-1};
vll dy{1,0,-1,0};


template <class type> void printVector(vector<type> vec){
    stringstream ss;
    ll n=vec.size();
    for(ll i=0;i<n;i++)
    {
        ss<<vec[i]<<" ";
        if(i!=n-1)ss<<" ";
    }
    cout<<ss.str()<<endl;
}

template <class type> void inputVector(vector<type>& vec){
    for(ll i=0;i<vec.size();i++)
    {
        cin>>vec[i];
    }
}
int main(){
    string S;
    cin>>S;
    if(S[S.size()-1]=='s') cout<<S+"es";
    else cout<<S+"s";
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>

 

 

 

 

 

 

 

using namespace std;

 

 

 

 

 

 

 

int main()
{
    int i, x;
    
    for(i=1; i<=10000; i++)
    
    {
        cin >> x;
        if (x==0)
       break;
        cout << "Case" << " "<< i << ":" << " " << x <<endl; 
    
   
      
    }
}


Measured memory_bytes: 3000
#include <stdio.h>
int main(){
    int h,o,p,t;
    char a[100];
    scanf("%d",&t);
    for(int i=0;i<t;i++){
        h=o=p=0;
        while(o<3){
            scanf("%s",a);
            if(a[1]=='I'){
                if(h>2)p++;
                else h++;
            }
            if(a[1]=='O'){
                p=p+h+1;
                h=0;
            }
            if(a[1]=='U'){
                o++;
            }
        }
        printf("%d\n",p);
    }
}

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

int main()
{
    int r, g, b;
    cin >> r >> g >> b;

    int num = r * 100 + g * 10 + b;

    if (num % 4 == 0) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3612
#include<stdio.h>
int main(){
  int n,a[100],i,j,turn=0,temp,min;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(a[j]<a[min])min=j;
    }
    if(i!=min){
      temp=a[i];
      a[i]=a[min];
      a[min]=temp;
      turn++;
    }
  }
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n%d\n",turn);
  return(0);
}

Measured memory_bytes: 604
<?php
$m = [];
for($i = 0; $i < 3; $i++){
    $m[$i] = array_map('intval', explode(' ', fgets(STDIN)));
}
$a[0] = 0;
for($i = 0; $i < 3; $i++) $b[$i] = $m[0][$i] - $a[0];
for($i = 0; $i < 3; $i++) $a[$i] = $m[$i][0] - $b[0];
$jdge = 'Yes';
for($i = 0; $i < 3; $i++){
    for($j = 0; $j < 3; $j++){
        if($a[$i] + $b[$j] != $m[$i][$j]) $jdge = 'No';
    }
}

echo $jdge;

Measured memory_bytes: 4604
def hamb(n,x):
  if x<=n:return 0
  elif x==1 and n==0:return 1
  elif x<=s[n-1]+1:return hamb(n-1,x-1)
  elif x==s[n]:return p[n]
  else:return hamb(n-1,x-2-s[n-1])+p[n-1]+1
n,x=map(int,input().split())
s=[0]*(n+1)
p=[0]*(n+1)
s[0]=1
p[0]=1
for i in range(n):
  s[i+1]=3+2*s[i]
  p[i+1]=1+2*p[i]
print(hamb(n,x)) 

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

int main(){
  long long N;
  string S,T="111";
  cin >> N >> S;
  T.at(0)=S.at(0);
  T.at(1)=S.at(2);
  T.at(2)=S.at(3);
  int A=stoi(T);
  cout << N*A/100 << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define endl "\n"
#ifdef ONLINE_JUDGE
#define DEBUG(x)
#else
#define DEBUG(x) cout<<#x<<" : {"<<x<<"}"<<endl;
#endif
using namespace std;
typedef long long int lli;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli n;
	cin>>n;
	vector<char> v;
	while(n > 0){
		if(n%26 == 0){
			v.push_back('z');
			n /= 26;
			n--;
		}
		else{
			v.push_back(97 + (n%26) - 1);
			n /= 26;
		}
	}
	reverse(v.begin(), v.end());
	for(int i=0; i<v.size(); ++i)
		cout<<v[i];
	cout<<endl;
    return 0;
}


Measured memory_bytes: 3592
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;
const int NIL = -1;

struct Node{
    int p, l, r;
};

vector<Node> T(30, {NIL, NIL, NIL});

void preOrder(int u){
    cout << ' ' << u;
    if(T[u].l != NIL) preOrder(T[u].l);
    if(T[u].r != NIL) preOrder(T[u].r);
}

void inOrder(int u){
    if(T[u].l != NIL) inOrder(T[u].l);
    cout << ' ' << u;
    if(T[u].r != NIL) inOrder(T[u].r);
}

void postOrder(int u){
    if(T[u].l != NIL) postOrder(T[u].l);
    if(T[u].r != NIL) postOrder(T[u].r);
    cout << ' ' << u;
}

int main(){
    int N;
    cin >> N;
    rep(i, N){
        int id, left, right;
        cin >> id >> left >> right;
        T[id].l = left;
        T[id].r = right;
        if(left != NIL) T[left].p = id;
        if(right != NIL) T[right].p = id;
    }

    int root;
    rep(i, N){
        if(T[i].p == NIL){
            root = i;
            break;
        }
    }

    cout << "Preorder" << endl;
    preOrder(root);
    cout << endl;

    cout << "Inorder" << endl;
    inOrder(root);
    cout << endl;

    cout << "Postorder" << endl;
    postOrder(root);
    cout << endl;
    
}


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


int main() {

   ios::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);

   string s, t;
   cin >> s >> t;
   
   if (s == t.substr(0, s.length()))
      cout << "Yes" << endl;
   else
      cout << "No" << endl;

   return 0;
}  

Measured memory_bytes: 3644
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var devide = new[] { "dream", "dreamer", "erase", "eraser" };
            var S = Console.ReadLine();

            var dp = new bool[S.Length + 1];

            dp[0] = true;
            for (var i = 0; i < S.Length; i++)
            {
                if (!dp[i]) continue;
                foreach (var d in devide)
                {
                    if (S.Substring(i, Math.Min(S.Length - i, d.Length)) == d)
                    {
                        dp[i + d.Length] = true;
                    }
                }
            }

            var output = dp[S.Length] ? "YES" : "NO";
            Console.WriteLine(output);
        }

        static int NumberOfDigits(long x)
        {
            if (x < 10) return 1;

            var result = 0;
            while (x > 0)
            {
                result++;
                x /= 10;
            }

            return result;
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }
    }
}


Measured memory_bytes: 15192
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto x = cast(long)(N / 1.08);
	if (cast(long)(x * 1.08) == N)
		writeln(x);
	else if (cast(long)((x+1) * 1.08) == N)
		writeln(x+1);
	else
		writeln(":(");

	stdout.flush;
	debug readln;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

const int MX = 2005;

bool d[3][3][2005];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> s(3);
    rep(i,3) cin >> s[i];
    sort(s.begin(), s.end());
    int ans = 6005;
    do
    {
        rep(i,3)rep(j,3)rep(k, s[i].size())
        {
            if(i >= j) continue;
            bool ok = true;
            for(int ni = k; ni < s[i].size(); ni++)
            {
                int nj = ni-k;
                if(nj >= s[j].size()) break;
                if(s[i][ni] == '?' || s[j][nj] == '?') continue;
                if(s[i][ni] != s[j][nj]) ok = false;
            }
            d[i][j][k] = ok;
        }
        auto f = [&](int i, int j, int k)
        {
            if(k >= s[i].size()) return true;
            return d[i][j][k];
        };

        rep(x,MX) rep(y,MX)
        {
            if(!f(0,1,x)) continue;
            if(!f(1,2,y)) continue;
            if(!f(0,2,x+y)) continue;
            int now = 0;
            now = max<int>(now, s[0].size());
            now = max<int>(now ,x+s[1].size());
            now = max<int>(now, x+y+s[2].size());
            ans = min(ans, now);
        }

    }
    while(next_permutation(s.begin(), s.end()));
    cout << ans << endl;
    return 0;
}


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

using ull = unsigned long long;
using ui = unsigned int;
ull tab[100500]{};
int main() {

	ui n{};
	std::cin >> n;
	std::vector<ull> v;
	v.resize(n);

	for (ui i{}; i < n; ++i)
		std::cin >> v[i];

	std::sort(std::begin(v), std::end(v));

//	std::cout << "\n";
	for (ui i{ 0 }; i < n / 2 + n % 2 == 0 ? 0 : 1; ++i) {
		//std::cout << "i " << n-i-1 << "\n";
		auto ti = 2 * i + (i % 2 == 0 ? 1 : 0);
		//		std::cout <<"i, ti "<<i<<", "<< ti << "\n";
		tab[ti] = v[n - i - 1];
	}

	//	std::cout << "\n";
	for (ui i{ 0 }; i < n / 2; ++i) {
		auto ti = 2 * i + (i % 2 == 0 ? 0 : 1);
		//		std::cout << "i, ti " << i << ", " << ti << "\n";
		tab[ti] = v[i];
	}



	auto lit = std::find(std::begin(tab), std::end(tab), 0);
	auto it = lit + 1;
	if (it != std::end(tab) && *it != 0)
		std::iter_swap(lit, it);


//	std::cout << "t " << tab[1] << " " << tab[0] << "\n";
	ull result = tab[1] - tab[0];
	ull d{};
	for (ui i{ 2 }; i < n; ++i) {

		if (tab[i] != 0 && tab[i - 2] != 0)
			d = (i - 1) % 4 < 2 ?
			tab[i] - tab[i - 2]
			: tab[i - 2] - tab[i];

		result += d;
//		std::cout << d << "\n";
	}

	auto mid = v[n / 2];
	
	auto r3 = n % 4 == 3;
	auto r1 = n % 4 == 1;

	auto ld = mid - v[n / 2 - 1];
	auto rd = v[n / 2 + 1] - mid;

	//auto ld_gt_rd = ld < rd;
//	std::cout << "l,r " << ld << " " << rd<<"\n";
	if (
 		   (r3 && ld < rd) || (r1 && ld > rd)
		) {
		auto d =  std::max(ld,rd) - std::min(ld,rd);
		result += d;
//		std::cout << "d " << d << "\n";
	}

	std::cout << result << "\n";
	//for (auto&e : tab)
	//	if (e != 0)
	//		std::cout << e << " ";


	return 0;
}

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

using namespace std;

int N, D, X, A[111];
int main(void){
	scanf("%d", &N);
	scanf("%d %d", &D, &X);
	for(int i = 0;i < N;++i) scanf("%d", A + i);
	int s = X;
	for(int i = 1;i <= D;++i){
		for(int j = 0;j < N;++j){
			if((i-1) % A[j] == 0) ++s;
		}
	}
	printf("%d\n", s);
	return 0;
}

Measured memory_bytes: 256
S =str(input())
S.split()

kisu = ['R', 'U', 'D']
gusu = ['L', 'U', 'D']
c = 0

for i in range(len(S)):
  if i%2 == 0:
    if S[i] in kisu:
      c += 1
  else:
    if S[i] in gusu:
      c += 1
      

if c == len(S):
  print('Yes')
else:
  print('No')
      


Measured memory_bytes: 8988
n = int(input())
a = [int(i) for i in input().split()]
c = 0
d = 0
for i in range(n):
    if a[i] < 0:
        c += 1
        a[i] *= -1
    if a[i] == 0:
        d += 1

c %= 2

if d > 0:
    c = 0

#print(c)

if c == 0:
    print(sum(a))
else:
    print(sum(a) - 2 * min(a))


Measured memory_bytes: 14224
from collections import deque

K = int(input())

visited=[False]*K
s=(1,1)

q = deque()
q.append(s)

while True:
  c = q.popleft()
  visited[c[0]] = True

  if c[0] == 0:
    print(c[1])
    exit()

  if not visited[(c[0] * 10) % K] and not visited[(c[0] * 10) % K]:
    q.appendleft(((c[0] * 10) % K, c[1]))

  if not visited[(c[0] + 1) % K] and not visited[(c[0] + 1) % K]:
    q.append(((c[0] + 1) % K, c[1] + 1))

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> A(N);
    rep (i, N) {
        cin >> A[i];
    }

    ll memo = 0;
    ll index = 0;
    map<ll, ll> m;
    rep (i, N) {
        m[A[i]]++;
        if (A[i] > memo) {
            memo = A[i];
            index = i;
        }
    }

    ll sec = 0;
    if (m[memo] > 1) {
        rep (i, N) {
            cout << memo << endl;
        }
    } else {
        rep (i, N) {
            if (A[i] != memo) {
                sec = max(sec, A[i]);
            }     
        }
        rep (i, N) {
            if (A[i] == memo) {
                cout << sec << endl;
            } else {
                cout << memo << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 10624