akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;

  vector<int> cnt(N, 0);
  REP(i,1,N+1){
    int j=i;
    while(j<=N){
      cnt[j]++;
      j+=i;
    }
  }
  ll ret = 0;
  REP(i,1,N){
    ret += cnt[i];
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 7064
N, M = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.sort()
y.sort()
mod = 10 ** 9 + 7
#重なりのない無数の小長方形を作って考える
#全ての長方形はこの小長方形の組み合わせで作られる
#小長方形ごとに面積を求め、他の長方形の組み立てに寄与する回数を掛ける
#小長方形ごとの計算をしてるとあれなので辺ごとにして、片方はすでに和をとっておくと計算量落ちる
xe = [0] * (N - 1)
ye = [0] * (M - 1)
for i in range(N - 1):
  xe[i] = abs(x[i + 1] - x[i]) * (N - i - 1) * (i + 1)
for i in range(M - 1):
  ye[i] = abs(y[i + 1] - y[i]) * (M - i - 1) * (i + 1)
sumxe = sum(xe)
res = 0
for yi in ye:
  res = (res + sumxe * yi) % mod
print(res)



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

#define ED return 0;
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) int(pow(x,y))
const long long mod = 1000000007;

int main() {
    int N, i;
    cin >> N >> i;
    cout << N - i + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int N, K;
	string S;
	cin >> N >> K >> S;
	S[K - 1] -= 'A' - 'a';
	cout << S << endl;

	return 0;
}

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

int main()
{
   ll n;
   cin>>n;
   string str;
   cin>>str;
   ll rcount{};
   for(auto &i:str)
      if(i == 'R')
         rcount++;
   ll ans{};
   for(ll i = 0;i<rcount;i++)
      if(str[i] == 'W') 
         ans++;
   cout<<ans;
   return 0;
   
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int i,j,k,l,n,m;
 cin>>n>>m;
 for(i=n-1;i>=0;i--)
 {
 	cout<<m-i<<" ";
 }
 for(i=1;i<n;i++)
 {
 	cout<<m+i<<" ";
 }
 return 0;
}

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

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
  #define cerrendl 42
#endif
//}}}

signed main() {
  int a,b,c;cin>>a>>b>>c;
  set<int> s;
  s.insert(a);
  s.insert(b);
  s.insert(c);
  if (sz(s)==2){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


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

using namespace std;
using ll = long long;

//cout << std::fixed << std::setprecision(15) << y << endl;

int main() {
    int n = 0;
    cin >> n;
    int MAX,SEMI = 0;
    int mNum = 0;
    for(int i = 0;i < n;i++){
        int tmp = 0;
        cin >> tmp;
        if(MAX < tmp){
            MAX = tmp;
            mNum = i;
            continue;
        }
        if(SEMI < tmp){
            SEMI = tmp;
            continue;
        }
    }
    for(int i = 0;i < n;i++){
        if(i != mNum){
            cout << MAX << endl;
        }else{
            cout << SEMI << endl;
        }
    }
    return 0;
}

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

typedef long long int ll;
ll N,C;

ll func(vector<ll>&vec_x, vector<ll>&vec_v){
  vector<ll>max_values;
  ll max_value = 0;
  ll sum_v = 0;
  
  for(int i = 0 ; i < N ; i++){
    sum_v += vec_v[i];
    max_values.push_back(max_value);
    max_value = max(max_value,sum_v - (vec_x[i]) * 2);
  }
  max_values.push_back(max_value);

  sum_v = 0;
  ll ret = 0;
  for(int i = N-1 ; i >= 0 ; i--){
    sum_v += vec_v[i];
    ret = max(ret, sum_v - (C - vec_x[i]) + max_values[max(0,i)]);
  }

  return ret;
}

int main(){
  cin >> N >> C;
  vector<ll>vec_x,vec_v;
  for(int i = 0 ; i < N ; i++){
    ll x,v;
    cin >> x >> v;
    vec_x.push_back(x);
    vec_v.push_back(v);
  }
  ll res = 0;
  res = func(vec_x, vec_v);
  reverse(vec_x.begin(), vec_x.end());
  for(int i = 0 ; i < vec_x.size() ; i++){
    vec_x[i] = (C - vec_x[i]);
  }
  reverse(vec_v.begin(), vec_v.end());
  res = max(res,func(vec_x, vec_v));
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define lli long long int
#define pb(a) push_back(a)
#define forr(a,n) for(lli i=a;i<n;i++)
#define forrr(j,a,n) for(lli j=a;j<n;j++)
#define all(x) x.begin(),x.end()
#define pi2  1.57079632679489661923
using namespace std;
void print(lli a[],lli n){
forr(0,n){cout<<a[i]<<" ";}
cout<<"\n";
}
lli power(lli x){
lli u=0;
while(x%2==0){
    u++;
    x=x/2;
}
return u;
}

lli powM(lli x,lli y,lli m)
{
    lli ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
int powm(lli a, lli b) {
	lli res = 1;
	while (b) {
		if (b & 1)
			res = (res * a);
		a = (a * a);
		b >>= 1;
	}
	return res;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
/*
vector <lli> adj[100001];
lli vis[100001]={0};
void dfs(lli a){
    vis[a]=1;
    forr(0,adj[a].size()){
    if(vis[adj[a][i]]){continue;}
    else{
        dfs(adj[a][i]);
    }
    }
}
lli level[100001];
void bfs(lli a){
queue <lli> q;
vis[a]=1;
level[a]=0;
q.push(a);
while(!q.empty()){
    lli p=q.front();
    q.pop();
    forr(0,adj[p].size()){
    if(vis[adj[p][i]]==0){
        level[adj[p][i]]=level[p]+1;
        q.push(adj[p][i]);
        vis[adj[p][i]]=1;
    }
    }

}

}

vector <pair<lli,lli> > dj[100001];
lli dist[100001];
vector<lli> ans[100001];
void dijkstra(lli a){
dist[a]=0;
ans[a].pb(a);
multiset<pair<lli,lli> > s;
s.insert({0,a});
while(s.size()!=0){
    lli x=(*s.begin()).second;
    s.erase(s.begin());
    if(vis[x]){continue;}
    vis[x]=1;
    forr(0,dj[x].size()){
    lli e=dj[x][i].first;
    lli we=dj[x][i].second;
    if(dist[x]+we<dist[e]){
        dist[e]=dist[x]+we;
        ans[e].clear();
        ans[e].pb(x);
        s.insert({dist[e],e});
    }
    }
}

}
*/
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
   cout.tie(0);
   // freopen("outpu.txt","w",stdout);
int t1=1;
//cin>>t1;
lli M =1e9+7;
while(t1--){
lli n;
cin>>n;
lli a[n];
lli u=0;
forr(0,n){
cin>>a[i];
if(i%2==0 && a[i]%2==1){u++;}
}
cout<<u;
}
     return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    string s; cin >> s;
    if(s.size() == 3) reverse(s.begin(),s.end());
    cout << s;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;

char s[25];
ll dp[25][2][2][5];

int main(){
  scanf("%s",s);
  int n = strlen(s);
  dp[0][0][0][0] = 1;
  REP(keta,n)REP(gochiusa,2)REP(less,2)REP(state,5){
    int c = s[keta]-'0';
    REP(d,10){
      if(!less && (d>c))continue;
      int nless = less || (d<c);
      int nstate = 0;
      if(state==0 && d==5)nstate = 1;
      if(state==1 && d==1)nstate = 2;
      if(state==2 && d!=5)nstate = 3;
      if(state==2 && d==5)nstate = 4;
      if(state==3 && d==3)nstate = 5;
      if(state==4 && d==3)nstate = 5;
      if(state==4 && d==1)nstate = 2;
      int ngo = gochiusa || (nstate==5);
      nstate %= 5;
      if(nstate==0 && d==5)nstate = 1;
      dp[keta+1][ngo][nless][nstate] += dp[keta][gochiusa][less][state];
    }
  }
  ll ans = 0;
  REP(less,2)REP(state,5)ans += dp[n][1][less][state];
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 3232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define ll long long int
#define pb push_back
#define llu unsigned long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define eb emplace_back
#define M 1000000007
#define vi vector<int>
#define vlli vector<lli>
#define pi pair<int,int>
#define mp make_pair
#define mapi map<int,int>

using namespace std;
ll max(ll x,ll y)
{
	if(x>y)
		return x;
	return y;
}
ll min(ll x,ll y)
{
	if(x<y)
		return x;
	return y;
}
int binaryToDecimal(string n) 
{ 
    string num = n; 
    int dec_value = 0;
    int base = 1; 
    int len = num.length(); 
    for (int i = len - 1; i >= 0; i--) 
	{ 
        if (num[i] == '1') 
            dec_value += base; 
        base = base * 2; 
    } 
    return dec_value; 
} 
ll findProductSum(ll A[], ll n) 
{ 
    ll array_sum = 0; 
    for (ll i = 0; i < n; i++) 
        array_sum = array_sum + A[i]; 
    ll temp = array_sum;
    ll array_sum_square = temp * temp;
    ll individual_square_sum = 0;
    for (ll i = 0; i < n; i++) 
        individual_square_sum += A[i]*A[i]%1000000007; 
    return (array_sum_square - individual_square_sum)/2 %1000000007; 
}
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cin.ignore(numeric_limits<streamsize>::max(),'\n');
    //const unsigned ll M=1000000007;
    ll n;
    cin >> n;
    if(n==1) cout << 0;
    else cout << 1;
    return 0;
}



Measured memory_bytes: 3648
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    vector<int>A(3);

    bool hasEven = false;
    REP(i, 3) {
        cin >> A[i];
        hasEven |= (A[i] % 2 == 0);
    }
    sort(A.begin(), A.end());

    if (hasEven) {
        cout << 0 << endl;
    }
    else {
        cout << A[0] * A[1] << endl;
    }


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
using namespace std;

int main(){
	string s, t;
	cin >> s >> t;
	cout << t << s << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,_N=N;I<_N;I++)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(i,N){R(x)V.push_back(x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL0(line)
#define P(X) std::cout<<(X)<<std::endl;
int main() {
  R(N)RV(s,N);
  std::vector<i8t> arr1(100*100+1, 0);
  arr1[0]=1;
  F(i,N){
    auto s1=s[i];
    for(int t=N*100;t--;){
      if(arr1[t])arr1[t+s1]=1;
    }
  }
  for(int i = N*100;i>=0;i--){
    if(i%10!=0&&arr1[i]){
      P(i);return 0;
    }
  }
  P(0)return 0;
}





Measured memory_bytes: 384
import numpy as np
import bisect
import itertools

#N, K = map(int, input().split())
#A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#LR = [list(map(int, input().split())) for _ in range(D)]

N, A = map(int, input().split())
X = [int(i)-A for i in input().split()]

SIZE = N*50
## dp[i][SIZE+j]: i番目までの数字を使って、平均がjになる組み合わせの総数
## 初期化
dp = [[0 for i in range(2*SIZE+1)] for j in range(N+1)]
for i in range(2*SIZE+1): dp[0][i] = 0
dp[0][SIZE] = 1 ## dp[N][SIZE]が答え
  
## DP
for i in range(N):
  for j in range(2*SIZE+1):
    if j-X[i]<0 or j-X[i]>2*SIZE:
      dp[i+1][j] = dp[i][j]
    else:
      dp[i+1][j] = dp[i][j] + dp[i][j-X[i]]

print(dp[N][SIZE]-1)

Measured memory_bytes: 14656
//written_by: Poushi
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main()
{
   long long int n,k,i;
   scanf("%lld", &n);
   long long int ara[n], taka, yen=1000;
   for(i=0; i<n; i++)
    scanf("%lld", &ara[i]);
    for(i=0;i<n-1;i++)
    {
        if(ara[i]<ara[i+1])
        {
            taka=yen/ara[i];
            yen-=(taka*ara[i]);
            yen+=(taka*ara[i+1]);
        }
    }
    printf("%lld\n", yen);
}


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

struct tabelog{
    string city;
    int p;
    int id;

    bool operator<( const tabelog& right ) const {
        return city == right.city ? p > right.p : city < right.city;
    }
};

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

    vector<tabelog> tv(n);
    for(int i = 0;i < n;i++){
        cin >> tv[i].city >> tv[i].p;
        tv[i].id = i+1;
    }
    sort(tv.begin(),tv.end());

    for(int i = 0;i < n;i++){
        cout << tv[i].id << endl;
    }
}

Measured memory_bytes: 256
class List
  def initialize
    @head = Node.new(nil)
    @tail = Node.new(nil)
    @head.next = @tail
    @tail.prev = @head
  end

  def insert(x)
    v = Node.new(x)
    left, right = @head, @head.next
    left.next, right.prev = v, v
    v.prev, v.next = left, right
  end

  def deleteFirst
    @head.next.unlink
  end

  def deleteLast
    @tail.prev.unlink
  end

  def delete(x)
    u = @head.next
    until u == @tail
      v = u.next
      if u.value == x
        u.unlink 
        return
      end
      u = v
    end
  end

  def to_s
    a = []
    v = @head.next
    until v == @tail
      a << v.value
      v = v.next
    end
    a * " "
  end

  class Node
    def initialize(x)
      @value = x
      @next = @prev = nil
    end

    attr_accessor :value, :next, :prev

    def unlink
      left, right = @prev, @next
      left.next = right
      right.prev = left
    end
  end
end

n = gets.to_i
list = List.new
n.times do
  command, x = gets.chomp.split
  if x 
    list.send(command, x.to_i)
  else
    list.send(command)
  end
end
puts list



Measured memory_bytes: 60440
#include<stdio.h>
#include<cmath>
using namespace std;

main(){
  int s, n, u, sum = 0;
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ){
    scanf("%d", &s);
    u = sqrt(s)+1;
    bool f = false;
    for ( int y = 1; y <= u; y++ ){
      if ( (s-y)%(2*y+1) == 0) { f = true; break; }
    }
    if ( !f ) sum++;
  }
  printf("%d\n", sum);
}

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

 int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a<=c && c<=b){cout <<"Yes" << endl;}
    else
    {
       if(a>=c && c>=b){cout <<"Yes" << endl;}
       else{cout << "No" << endl;}
    }
    
 }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main ()
{
  //declaring vars 
  int yenCoins;
  cin>>yenCoins;
//logic
  int int1 =yenCoins/500;
  int happinesCoins = int1*1000;
  int remainingCoins=yenCoins-(int1*500);

  int int2=remainingCoins/5;
  happinesCoins+=5*int2;
//output
  cout<<happinesCoins<<endl;
  return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue
#include <map>
#include <set> //multiset set<int,greater<int>>大到小
#include <vector>// ::iterator it;
#include <stack>
#include <cmath> // auto &Name : STLName  Name.
#include <utility>
#include <sstream>
#include <string>//__builtin_popcount(ans);//获取某个数二进制位1的个数
#define mod 1000000007
#define mod9 998244353
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ld;
const db eps=1e-10;
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int N=1e5+7;
using namespace std;

ll t,n,m,k,ans=0;
int main(){
    scanf("%lld",&n);
    printf("%lld\n",(1+n-1)*(n-1)/2);
}

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

int LinerSearch(int A[], int n, int key){
	int i = 0;
	
	A[n] = key;
	while(A[i] != key){
		i++;
	}
	return i;
}


int main(){
	int n, s[10100], q, key, count = 0;
	int i, j, k;
	
	cin>>n;
	
	for(i = 0; i < n; i++) cin>>s[i];
	
	cin>>q;
	
	for(i = 0; i < q; i++){
		 cin>>key;
		 if(LinerSearch(s, n, key) != n) count++;
	}
	
	cout<<count<<endl;	
	
	return 0;
}


Measured memory_bytes: 3120
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] pri=new int[300000];
		int[] pri_true=new int[300000];
		int k=0;

		for(int i=1;i<300000;i++){
            pri[i] = i;
        }
        for(int i=2;i<300000;i++){
            for(int j=i+i;j<300000;j+=i){
                pri[j]=0;
            }
        }

		for(int i=2;i<300000;i++){
			//素数をpri_trueに格納
			if(pri[i]!=0 && pri[i]%10==1){
				pri_true[k]=pri[i];
				k++;
			}
		}

		for(int i=0;i<n;i++){
        	System.out.print(pri_true[i]+" ");
        }

        System.out.println();

	}
}

Measured memory_bytes: 24148
#!/usr/bin/env python3
s = list(input())
t = list(input())
n = len(s)
m = len(t)
for i in range(n - m + 1)[::-1]:
    for j in range(m):
        if s[i + j] != '?' and s[i + j] != t[j]:
            break
    else:
        s[i:i + m] = t
        for k in range(n):
            if s[k] == '?':
                s[k] = 'a'
        print(''.join(s))
        exit()
print('UNRESTORABLE')



Measured memory_bytes: 3064
n,m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
answer = 0
for i in range(1,m+1):
    count = 0
    for j in range(n):
        for k in range(1,a[j][0]+1):
            if i == a[j][k]:
                count += 1
    if count == n:
        answer += 1
print(answer)

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

     public static void main(String []args) throws IOException{
       
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       
       String a[] = br.readLine().split(" ");
       
        int n = Integer.parseInt(a[0]);
        int k = Integer.parseInt(a[1]);
        Set<Integer> st = new HashSet<>();
        while(k-->0) {
            int count= Integer.parseInt(br.readLine());
            
            String array[] = br.readLine().split(" ");
            for(String x: array) st.add(Integer.parseInt(x));
            
        }
        
        System.out.println(n-st.size());
     }
}

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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int n;

int func(string s) {
  int len = (int)s.size();
  int res = 0;
  for (int i = 0; i < len; i++) {
    res += (int)(s[i] - '0');
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  //stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  //if (stream2 == NULL) return 0;
#endif
  cin >> n;
  int ans = 1000000000;
  for (int i = 1; i < n; i++) {
    string s = to_string(i);
    string t = to_string(n - i);
    int sum = func(s) + func(t);
    ans = min(ans, sum);
  }
  cout << ans << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b)  for (__typeof(b) i=(a)-((a)>(b));i!=(b)-((a)>(b));i+=1-2*((a)>(b)))
using namespace std;
int main(){
	int t=1;
//	cin>>t;
	while(t--){
		
	 int n; cin >> n;
	 int a[n];
	 
	 for(int i=0;i<n;i++){
	 	cin >> a[i];
	 }
	 
	 map<int,int> dp;
	 dp[0] = 0;
	 int ans = 0;
	 
	 for(int i=0;i<n;i++){
	 	int t = a[i];
	 	dp[t] = dp[t-1] + 1;
	 	ans=max(ans,dp[t]);
	 }
	 
	 cout << n-ans;
	 cout << endl;
  }
    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
using lint = long int;
using llint = long long int;
using namespace std;

int main() {
    fastIO;
    string s, t;
    cin >> s >> t;

    int cnt = 0;
    for (size_t i = 0; i < s.size(); i++) {
        if (s.at(i) != t.at(i))
            cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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; }

int main(){
    int n,m;
    cin>>n>>m;
    int k[m],s[m][n],p[m];
    for(int i=0;i<m;i++){
        cin>>k[i];
        for(int j=0;j<k[i];j++){
            int t;
            cin>>t;
            t--;
            s[i][j]=t;
        }
    }
    for(int i=0;i<m;i++){
        cin>>p[i];
    }
    int ans=0;
    for(int bit=0;bit<(1<<n);bit++){
        bool fullon=true;
        for(int i=0;i<m;i++){
            int on=0;
            for(int j=0;j<k[i];j++){
                if(bit & (1<<s[i][j])) on++;
            }
            if(on%2!=p[i]) fullon=false;
        }
        if(fullon) ans++;
    }
    cout<<ans<<endl;
}

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

int main(){
    long n, k;
    std::cin >> n >> k;
    std::vector<int> a(n);
    std::vector<int> cnt(n + 1, 0);
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
        ++cnt[a[i]];
    }

    cnt.erase(std::remove(cnt.begin(), cnt.end(), 0), cnt.end());
    std::sort(cnt.begin(), cnt.end());

    int res = 0;
    if(k >= cnt.size()){
        res = 0;
    }else{
        res = std::accumulate(cnt.begin(), cnt.begin() + cnt.size() - k, 0);
    }
    std::cout << res << std::endl;

    return 0;
}


Measured memory_bytes: 1792
S = input()
mod_list = [0 for i in range(2019)]
mod_list[0] += 1
number = 0
ten_count = 1
for s in S[::-1]:
    number += pow(10, ten_count, 2019) * int(s)
    ten_count += 1
    mod_list[number % 2019] += 1

ans = 0
for i in mod_list:
    if i > 1:
        ans += i * (i - 1) // 2

print(ans)

Measured memory_bytes: 9180
A  = input()
B = input()
if len(A) > len(B):
    print("GREATER")
elif len(A) < len(B):
    print("LESS")
else:
    decided = False
    for i in range(len(A)):
        if int(A[i]) < int(B[i]):
            print("LESS")
            decided = True
            break
        elif int(A[i]) > int(B[i]):
            print("GREATER")
            decided = True
            break
    if not decided:
        print("EQUAL")

Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();


        int sum = Math.abs(a-b) + Math.abs(b-c) + Math.abs(a-c);
        sum -= Math.max( Math.max( Math.abs(a-b), Math.abs(b-c)), Math.abs(a-c));

        System.out.println(sum);
    }
}

Measured memory_bytes: 23124
#include"iostream"
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include<list>
#include<map>
#include<string>
#include<algorithm> 
#include <queue> 
#include <sstream>
#include <fstream>
#include<cmath>
#define INF 100000000000
#define LL long long
using namespace std;
map<LL, LL> m;
long long N, M, K,Q, ans, A[100001], B[100001], ss[100001],a[100000], b[100000];

string s;

LL gcd(LL x, LL y) {
	if (x < y) {
		LL c = x;
		x = y;
		y = c;
	}
	if (y == 0)return x;
	if (x%y == 0) {
		return y;
	}
	else {
		return gcd(y, x%y);
	}
}
int main() {
	cin >> N>>M;
	if (abs(N - M)>1) {
		cout << 0 << endl;
		return 0;
	}
	if ((N + M) % 2 == 0) {
		K = 1;
		Q = 1;
		for (int i = 1; i <= N; i++) {
			K = K*i % 1000000007;
		}
		for (int i = 1; i <= M; i++) {
			Q = Q*i % 1000000007;
		}
		ans = 2 * Q*K % 1000000007;
	}
	else {
		K = 1;
		Q = 1;
		for (int i = 1; i <= N; i++) {
			K = K*i;
			K = K % 1000000007;
		}
		for (int i = 1; i <= M; i++) {
			Q = Q*i;
			Q = Q % 1000000007;
		}
		ans = (Q*K) % 1000000007;
	}
	cout << ans << endl;
	
	
	return 0;
}

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

int main() {
	int n;
	cin>>n;
	int A[n];
	for(int i=1;i<=n;i++)
	cin>>A[i];
	
	int Dp[n];
	Dp[1]=0;
	Dp[2]=abs(A[2]-A[1]);

	for(int i=3;i<=n;i++)
	{
		Dp[i]=min(abs(A[i]-A[i-1])+Dp[i-1],abs(A[i]-A[i-2])+Dp[i-2]);
		// cout<<Dp[i]<<endl;
	}
	cout<<Dp[n];
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int a[10];
bool dfs(int i,int j,int k){
	return(k==10||(i<a[k]&&dfs(a[k],j,k+1))||(j<a[k]&&dfs(i,a[k],k+1)));
}
int main() {
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		for(int j=0;j<10;j++)cin>>a[j];
		cout<<(dfs(0,0,0)?"YES":"NO")<<endl;
	}
}

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


int main() {
  string S;
  cin >> S;
  string SS = S.substr(0, (S.size() - 1) / 2);
  string SSS = S.substr((S.size() + 1) / 2);
  string T(S.rbegin(), S.rend());
  string TT(SS.rbegin(), SS.rend());
  string TTT(SSS.rbegin(), SSS.rend());
  if (S == T && SS == TT && SSS == TTT) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N = II()
    P = LMIIS()
    count = 0
    min_p = P[0]
    for p in P:
        if p <= min_p:
            count += 1
            min_p = p
    print(count)


    

if __name__ == '__main__':
    main()

Measured memory_bytes: 71132
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

bool Compare(pair<int,int> a, pair<int,int> b)
{
    int l1=a.ss-a.ff+1;
    int l2=b.ss-b.ff+1;
    if(l1!=l2) return l1>l2;
    return a.ff > b.ff;
}
std::priority_queue<pii, std::vector<pii>, std::function<bool(pii, pii)>> pq(Compare);


void solve(){
  int x,k,d; cin>>x>>k>>d;
  if(x<0) x*=-1;
  int move=x/d;
  if(k<=move){
    int travel=d*k;
    x-=travel;
    cout<<x;
  }else{
    int rem=k-move;
    if(rem%2==0){
      x-=d*move;
      cout<<x;
    }else{
      x-=d*move;
      x-=d;
      cout<<abs(x);
    }
  }
}


int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int t=1; //cin>>t;
  while(t--) solve();
  return 0;
}
// check for overflows dummy !!!


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl
#define YORN(f) cout<<((f)?"YES":"NO")<<endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        cout << "Possible" << endl;
    }
    else {
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
using namespace std;
int fa[200000 + 5];
int dp[200000 + 5];
int find(int x) {
    return fa[x] == x ? x : fa[x] = find(fa[x]);
}
void merge(int x, int y) {
    fa[find(x)] = find(y);
}
int main() {
    int n, m;
    int max1 = 0;
    int max2 = 0;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        fa[i] = i;
    }
    for (int i = 1; i <= m; i++) {
        int a, b;
        cin >> a >> b;
        merge(a, b);
        //max1 = max({ max1,a,b });
    }
    for (int i = 1; i <= n; i++) {
        dp[find(i)]++;
    }
    for (int i = 1; i <= n; i++) {
        if (dp[i] > max2)
            max2 = dp[i];
    }
    cout << max2;
    return 0;
}

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

struct sorter{
	bool operator()(const pair<int,int> & a, const pair<int,int> & b){
		return a.second > b.second;
	}
};

int main(){
	int n, m, a, b;
	cin>>n>>m;
	vector<int> vec(n, 0);
	vector<pair<long long, long long> > go;
	for(int i = 0; i < n; ++i)cin>>vec[i];
	for(int i = 0; i < m; ++i){
		cin>>a>>b;
		go.push_back(make_pair(a, b));
	}
	sort(vec.begin(), vec.end());
	sort(go.begin(), go.end(), sorter());
	long long res = 0;
	for(auto x : go){
		long long b = x.first;
		long long c = x.second;
		auto xp = upper_bound(vec.begin(), vec.end(), c);

		if(b < (xp - vec.begin())){
			vec.erase(vec.begin(), vec.begin() + b);
			res += b * c;
		}
		else{
			vec.erase(vec.begin(), xp);
			res += (long long)(xp - vec.begin()) * c;
		}
	}
	for(auto v : vec)res += v;
	cout<<res<<endl;	
	return 0;
}


Measured memory_bytes: 3828
def main():
    array = list(input())
    for i, s in enumerate(array):
        if (i+1) % 2 == 0:
            if array[i] == 'R':
                print('No')
                return
            else:
                continue
        else:
            if array[i] == 'L':
                print('No')
                return
            else:
                continue
    print('Yes')



if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n=int(input())
c=list(map(int,input().split()))
c.sort(reverse=True)
res=0
ans=0
mod=10**9+7
p=pow(2,n*2-2,mod)
for i in range(n):
   ans+=(c[i]*(i+2)%mod)*p
print(ans%mod)


Measured memory_bytes: 87500
// 最大流を求めるアルゴリズム

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const int INF = INT_MAX;

struct Edge {
  int to;
  int cap;
  int rev;

  Edge(int to = -1, int cap = -1, int rev = -1) {
    this->to = to;
    this->cap = cap;
    this->rev = rev;
  }
};

const int MAX_V = 100;
bool used[MAX_V];
int V, E;
vector <Edge> G[MAX_V];

void add_edge(int from, int to, int cap) {
  G[from].push_back(Edge(to, cap, G[to].size()));
  G[to].push_back(Edge(from, 0, G[from].size() - 1));
}

int dfs(int v, int t, int f) {
  if (v == t) return f;

  used[v] = true;

  for (int i = 0; i < G[v].size(); ++i) {
    Edge *e = &G[v][i];

    if (!used[e->to] && e->cap > 0) {
      int d = dfs(e->to, t, min(f, e->cap));
      if (d > 0) {
        e->cap -= d;
        G[e->to][e->rev].cap += d;
        return d;
      }
    }
  }

  return 0;
}

int max_flow(int s, int t) {
  int flow = 0;
  for (;;) {
    memset(used, 0, sizeof(used));
    int f = dfs(s, t, INF);
    if (f == 0) return flow;
    flow += f;
  }
}

int main() {
  memset(used, false, sizeof(used));

  cin >> V >> E;

  int u, v, c;
  for (int i = 0; i < E; ++i) {
    cin >> u >> v >> c;

    add_edge(u, v, c);
  }

  cout << max_flow(0, V - 1) << endl;

  return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <tuple>

// さんこう :https://beta.atcoder.jp/contests/abc109/submissions/3153889
using namespace std;

typedef long long ll;

string S, T;
map <char, char> st, tt;

int main() {
   cin >> S;
   cin >> T;
   char i = 'a';
   for (int j=0;;j++) {
      auto itr = st.find(S[j]);
      if (itr == st.end()) {
         st[S[j]] = i++;
      }
      S[j] = st[S[j]];
      if (S[j+1] == '\0') {
         break;
      }
   }
   //cout << S << endl;

   i = 'a';
   for (int j=0;;j++) {
      auto itr = tt.find(T[j]);
      if (itr == tt.end()) {
         tt[T[j]] = i++;
      }
      T[j] = tt[T[j]];
      if (T[j+1] == '\0') {
         break;
      }
   }
   //cout << T << endl;
   if (S == T) {
      cout << "Yes" << endl;
   } else {
      cout << "No" << endl;
   }
   return 0;
}


Measured memory_bytes: 776
import sys
import heapq

n = int(sys.stdin.readline())

Q = []
adj = [[] for _ in range(n)]
for _ in range(n):
    cols = list(map(int, sys.stdin.readline().split()))
    for j in range(cols[1]):
        adj[cols[0]].append([cols[2+2*j], cols[2+2*j+1]])

d = [0] + [1e10] * (n-1)
color = [1] + [0] * (n-1)
heapq.heappush(Q, [0, 0])

while len(Q)>0:
    t, u = heapq.heappop(Q)
    color[u] = 2
    if d[u] < t: continue
    for v, w in adj[u]:
        if color[v] == 2: continue
        if d[v] > d[u] + w:
            d[v] = d[u] + w
            heapq.heappush(Q, [d[v], v])
            color[v] = 1

i=0
for e in d:
    print(i, e)
    i += 1


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

int main(void) {
    int n, k;
    long long ans = 0;
    cin >> n >> k;
    for (int i = k + 1; i <= n; i++) {
        ans += (n / i) * (i - k);
        if (k != 0 && n % i >= k) ans += n % i - k + 1;
        if (k == 0 && n % i > k) ans += n % i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char ch[305][305];
int tot=0,vis[305],ans[305][305];
int main(){
	int H,W,k;
	cin>>H>>W>>k;
	for(int i=1;i<=H;++i)
		for(int j=1;j<=W;++j)
			cin>>ch[i][j],vis[i]|=(ch[i][j]=='#');
	for(int i=1;i<=H;++i)
		if(vis[i]){
			int fl=0;
			for(int j=1;j<=W;++j)
				if(ch[i][j]=='#') ans[i][j]=++tot,fl=1;
				else ans[i][j]=(fl==1?tot:tot+1);
		}
	for(int i=2;i<=H;++i)
		if(vis[i-1] && !vis[i]){
			for(int j=1;j<=W;++j)
				ans[i][j]=ans[i-1][j];
			vis[i]=1;
		}
	for(int i=H-1;i>=1;--i)
		if(vis[i+1] && !vis[i]){
			for(int j=1;j<=W;++j)
				ans[i][j]=ans[i+1][j];
			vis[i]=1;
		}
	for(int i=1;i<=H;++i,puts(""))
		for(int j=1;j<=W;++j,putchar(' '))
			cout<<ans[i][j];
	return 0;
}

Measured memory_bytes: 4040
n,m=map(int,input().split())
if n%2==1:
  for i in range(1,m+1):
    print(i,n-i)
else:
  if m>n//4:
    for i in range(1,n//4+1):
      print(i,n-i+1)
    for i in range(1,m-n//4+1):
      print(n//2-i,n//2+i)
  else:
    for i in range(1,m+1):
      print(i,n-i+1)

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

#define MAX 10000000001

int a,b,q,s,t,x;
vector<int> shrine,temple,ans;

main() {
    cin >> a >> b >> q;
    rep(i,a) cin >> s,shrine.pb(s)
    rep(i,b) cin >> t,temple.pb(t)
    shrine.pb(0)
    shrine.pb(MAX)
    temple.pb(0)
    temple.pb(MAX)
    sort(all(shrine));
    sort(all(temple));
    rep(i,q) {
        cin >> x;
        int sum=1000000000000000000;
        vector<int>::iterator sf,tf;
        sf = lower_bound(all(shrine),x);
        tf = lower_bound(all(temple),x);
        if (*sf && *tf && *sf != MAX && *tf != MAX) {
            int tmp,sp = *sf,tp = *tf;
            tmp = max(abs(sp-x),abs(tp-x));
            sum = min(sum,tmp);
        }
        if (*(sf-1) && *(tf-1) && *(sf-1) != MAX && *(tf-1) != MAX) {
            int tmp,sp = *(sf-1),tp = *(tf-1);
            tmp = max(abs(sp-x),abs(tp-x));
            sum = min(sum,tmp);
        }
        if (*(sf-1) && *tf && *(sf-1) != MAX && *tf != MAX) {
            int tmp,sp = *(sf-1),tp = *tf;
            tmp = abs(sp-x) + abs(tp-x) + min(abs(sp-x),abs(tp-x));
            sum = min(sum,tmp);
        }
        if (*sf && *(tf-1) && *sf != MAX && *(tf-1) != MAX) {
            int tmp,sp = *sf,tp = *(tf-1);
            tmp = abs(sp-x) + abs(tp-x) + min(abs(sp-x),abs(tp-x));
            sum = min(sum,tmp);
        }
        ans.pb(sum)
    }
    rep(i,q) cout << ans[i] << endl;
}


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

int main(){
  int i,j,k,n,cnt=0;
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  double ma=0;int p=100*a,q=0;
  for(i=1;i<=30;i++){
    for(j=0;j<=30;j++){
      for(k=0;k<=3000;k++){
        for(n=0;n<=3000;n++){
          int M=100*(a*i+b*j)+c*k+d*n,m=c*k+d*n;
          if(M<=f && 100*m<=e*(M-m)){
            if(ma<(double)(100*m)/(double)M){
              ma=(double)(100*m)/(double)M;
              p=M;
              q=m;
            }
          }else break;
        }
      }
    }
  }
  cout<<p<<" "<<q<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  int tmp = 0;
  int ans = 0;
  rep(i, n) {
    if(s[i] == 'g') {
      if(tmp) {
        tmp--;
        ans++;
      } else {
        tmp++;
      }
    } else {
      if(tmp) {
        tmp--;
      } else {
        ans--;
        tmp++;
      }
    }
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 3716
#include <cstdio>
#include <numeric>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <array>
using i64 = long long;
using namespace std;

int main() {
  int n;
  cin >> n;
  i64 s = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0) continue;
    if (i % 5 == 0) continue;
    s += i;
  }
  cout << s <<  "\n";
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>

int main(void) {
  int n;
  std::string str;
  std::string::size_type id;
  
  std::cin >> n;
  std::cin.ignore();
  for(int i=0; i<n; i++) {
    getline(std::cin, str);
    while((id = str.find("Hoshino")) != std::string::npos) {
        str[id+6] = 'a';
    }
    std::cout << str << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1204
n = int(input())
s = input()
ans = 0
for i in range(1, n):
  t = s[0:i]
  t2 = s[i:n]
  t = list(set(t))
  t2 = list(set(t2))
  cnt = 0
  for j in t:
    if j in t2:
      cnt += 1
  ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdbool.h>

#define MAX 100
#define INFINITY (1LL << 32)

static int n;
static long long d[MAX][MAX];

static void floyd()
{
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            if (d[i][k] == INFINITY)
                continue;
            for (int j = 0; j < n; j++) {
                if (d[k][j] == INFINITY)
                    continue;
                long long tmp = d[i][k] + d[k][j];
                d[i][j] = (d[i][j] < tmp) ? d[i][j] : tmp;
            }
        }
    }
}

int main()
{
    int e, u, v, c;
    scanf("%d %d", &n, &e);

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            d[i][j] = (i == j) ? 0 : INFINITY;
        }
    }

    for (int i = 0; i < e; i++) {
        scanf("%d %d %d", &u, &v, &c);
        d[u][v] = c;
    }

    floyd();

    bool negative = false;
    for (int i = 0; i < n; i++) {
        if (d[i][i] < 0)
            negative = true;
    }

    if (negative) {
        printf("NEGATIVE CYCLE\n");
    } else {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (j > 0)
                    printf(" ");
                if (d[i][j] == INFINITY) {
                    printf("INF");
                } else {
                    printf("%lld", d[i][j]);
                }
            }
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n;
	cin >> n;
	int ans  = 0;
	ans = (n/500) * 1000;
	n %= 500;
	while(n > 5){
		ans += 5;
		n -= 5;
	}
	cout << ans;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;


// Vacation
long long dp[3][100001];
int main(int argc, char const *argv[]){
    int n, h[3][100001];
    cin >> n ;
    for(int i=0;i<n;i++){
        cin >> h[0][i] >> h[1][i] >> h[2][i];
        dp[0][i]=0;
        dp[1][i]=0;
        dp[2][i]=0;
    }
    dp[0][0]=h[0][0];
    dp[1][0]=h[1][0];
    dp[2][0]=h[2][0];
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++) {
            chmax(dp[j][i], dp[(j+1)%3][i - 1] + h[j][i]);
            chmax(dp[j][i], dp[(j+2)%3][i - 1] + h[j][i]);
        }
    }
    cout << max(max(dp[0][n-1], dp[1][n-1]),dp[2][n-1]) << endl;
}


Measured memory_bytes: 3712
#include <iostream>
#include <math.h>
#include <string>
using namespace std;

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

    int l;
    long stocks = 1000;

    for (long long i = 1; i*i <= n; i++) {
        if (n % i != 0) continue;
        l = log10(n/i) + 1;
        if (l < stocks) stocks = l;
        
    }

    cout << stocks << endl;

}

Measured memory_bytes: 3972
#include <iostream>
#include <stdio.h>
using namespace std;

int main(int argc, char const *argv[])
{
    int c = 10000;
    int a[c];

    int i = 0;

    cin >> a[i];
    i++;
    while(a[i-1] != 0){
        cin >> a[i];
        i++;
    }
    
    for(int j = 0; j < i-1; j++)
    {
        printf("Case %d: %d\n", j+1, a[j]);
    }
    
    return 0;
}



Measured memory_bytes: 3116
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int a[3];
   rep(i,3)   cin >> a[i];

   sort(a,a+3);

   if((a[0] == 5) && (a[1] == 5) && (a[2] == 7)) cout << "YES" << endl;
   else cout << "NO" << endl;
   
 


   return 0;
}

Measured memory_bytes: 256
from collections import deque
N,M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
  l,r,d = map(int, input().split())
  l,r = l-1,r-1
  E[l].append((r,d))
  E[r].append((l,-d)) 
  
#for e in E:
#  print(e)
  
# bfs
Q = deque()
visited = [False] * N
willSearch = [False] * N
INF = 10**16
A = [ INF ] * N

for i in range(N):
  if visited[i]:
    continue
  Q.append((i,-1,0))
  while Q:
    now, prev, num = Q.popleft()
    visited[now] = True
    if A[now] == INF:
      A[now] = num
    elif A[now] != num:
      # ある点において2通りのnum設定の仕方がある
      #print(now,prev,num,A[inxt])
      print("No")
      exit(0)
    for nxt, dis in E[now]:
      if nxt == prev:
        continue
      if A[nxt] < INF and A[nxt] != num + dis:
        # ある点において2通りのnum設定の仕方がある
        #print(now,prev,num, nxt,dis, A[nxt])
        print("No")
        exit(0)
      if visited[nxt] or willSearch[nxt]:
        continue
      Q.append((nxt, now, num + dis))
      willSearch[nxt] = True
    
print("Yes")


Measured memory_bytes: 115124