akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
int probA()
{
    int a,b;
    char s[101];
    // 整数の入力
    scanf("%d", &a);
    // スペース区切りの整数の入力
    scanf("%d",&b);
    // 文字列の入力
    scanf("%s",s);
    // 出力
    if(s[b-1]=='A'){s[b-1]='a';}
    if(s[b-1]=='B'){s[b-1]='b';}
    if(s[b-1]=='C'){s[b-1]='c';}
    
    printf("%s\n",s);
    return 0;
}

int probB(){
    int S,AA,BB;
    scanf("%d", &S);
    AA=S/100;
    BB=S%100;
    if(1<=AA && AA<=12){
        if(1<=BB && BB<=12){printf("AMBIGUOUS\n");}
        else{printf("MMYY\n");}
    }
    else{
        if(1<=BB && BB<=12){printf("YYMM\n");}
        else{printf("NA\n");}
    }
    
    
    
    return 0;
}



int Ipow2XK(int i,int K){
    int X;
    for(X=0;i*pow(2,X)<K;X++){
        
    }
    
    return X;
}

int probC(){
    
    int N,K;
    double R=0;
    scanf("%d %d", &N,&K);
    for(int i=1;i<=N;i++){
        R+=(double)1/(N*pow(2,Ipow2XK(i,K) )  );
    }
    
    
    printf("%1.12lf\n",R);
    return 0;
}

int main(){
    probC();
    return 0;
}


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

using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int count = 0;
    for(int i = 0; i < s.size()-2; i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') count++;
    }
    cout<<count;
    return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define pll pair<long long,long long>
using namespace std;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int i = 1;
        while(true){
            int x = sc.nextInt();

            if(x==0) {
                break;
            }else{
                System.out.println("Case " + i++ + ": " + x);
            }
        }
    }
}



Measured memory_bytes: 41496
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    string S;
    cin >> S;

    string t1 = "hi";
    string t2 = "hihi";
    string t3 = "hihihi";
    string t4 = "hihihihi";
    string t5 = "hihihihihi";

    string ans = "No";
    if (S == t1) ans = "Yes";
    if (S == t2) ans = "Yes";
    if (S == t3) ans = "Yes";
    if (S == t4) ans = "Yes";
    if (S == t5) ans = "Yes";

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

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

using namespace std;

int main()
{

	int z[9][81]={
		{1},
		{1,2,3,4},
		{1,2,6,3,5,7,4,8,9},
		{1,2,6,7,3,5,8,13,4,9,12,14,10,11,15,16},
		{1,2,6,7,15,3,5,8,14,16,4,9,13,17,22,10,12,18,21,23,11,19,20,24,25},
		{1,2,6,7,15,16,3,5,8,14,17,26,4,9,13,18,25,27,10,12,19,24,28,33,11,20,23,29,32,34,21,22,30,31,35,36},
		{1,2,6,7,15,16,28,3,5,8,14,17,27,29,4,9,13,18,26,30,39,10,12,19,25,31,38,40,11,20,24,32,37,41,46,21,23,33,36,42,45,47,22,34,35,43,44,48,49},
		{1,2,6,7,15,16,28,29,3,5,8,14,17,27,30,43,4,9,13,18,26,31,42,44,10,12,19,25,32,41,45,54,11,20,24,33,40,46,53,55,21,23,34,39,47,52,56,61,22,35,38,48,51,57,60,62,36,37,49,50,58,59,63,64},
		{1,2,6,7,15,16,28,29,45,3,5,8,14,17,27,30,44,46,4,9,13,18,26,31,43,47,60,10,12,19,25,32,42,48,59,61,11,20,24,33,41,49,58,62,71,21,23,34,40,50,57,63,70,72,22,35,39,51,56,64,69,73,78,36,38,52,55,65,68,74,77,79,37,53,54,66,67,75,76,80,81}
	};

	int n;
	int m=1;
	while(cin>>n,n){
		cout<<"Case "<<m++<<":"<<endl;
		for(int i=0;i<n*n;i++){
			printf("%3d",z[n-1][i]);
			if(i%n==n-1) cout<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1208
n,m = map(int,input().split())

#H = list(range(1, n+1))
#print(H)

H = list(map(int, input().split()))
#print(H)

flag = [1] * n
#print(flag)

for i in range(m):
  a,b = map(int, input().split())
  #print(a, b)
  #print("aの高さ:" + str(H[a-1]))
  #print("bの高さ:" + str(H[b-1]))
  if H[a-1] <= H[b-1]:
    flag[a-1] = 0
    #print(str(a)+"はいい展望台じゃないよ")
  if H[b-1] <= H[a-1]:
    flag[b-1] = 0
    #print(str(b)+"はいい展望台じゃない~")
  #print(flag)
#print(flag)
count = 0
for f in flag:
  if f:
    count += 1
print(count)

Measured memory_bytes: 20112
#include <stdio.h>
#define MOD 1000000007LL

int main(void) {
	int n,m;
	long long int x[100000],y[100000];

	scanf("%d %d",&n,&m);
	for (int i = 0;i < n;i++) {
		scanf("%lld",&x[i]);
	}
	for (int i = 0;i < m;i++) {
		scanf("%lld",&y[i]);
	}
	
	long long int sumx = 0LL;
	long long int tmp;
	for (int i = 0;i < n-1;i++) {
		tmp = (x[i+1]-x[i])*(i+1);
		tmp %= MOD;
		tmp *= (n-1-i);
		tmp %= MOD;
		sumx += tmp;
		sumx %= MOD;
	}
	long long int sumy = 0L;
	for (int i = 0;i < m-1;i++) {
		tmp = (y[i+1]-y[i])*(i+1);
		tmp %= MOD;
		tmp *= (m-1-i);
		tmp %= MOD;
		sumy += tmp;
		sumy %= MOD;
	}
	printf("%lld\n", (sumx*sumy)%MOD);
	
	return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
//const int mod = 1e9 + 7;
const int mod = 998244353;
const double eps = 1e-9;

/*{
  }*/

signed main(){
  int n;
  cin >> n;
  
  vi x(n), y(n);
  rep(i, 0, n) cin >> x[i] >> y[i];

  vector<vector<double>> d(n, vector<double>(n));
  rep(i, 0, n) rep(j, 0, n){
    d[i][j] = sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
  }

  double ans = 0.0f;
  rep(i, 0, n) rep(j, 0, n){
    ans += d[i][j]/n;
  }

  printf("%.9f\n", ans);

  return 0;
}



Measured memory_bytes: 256
/* Manish Pant - insider_pants */

#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
    #include "debug.h"
#endif

#define F first
#define S second
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int main()
{
    ll a;
    ldob b; 
    cin >> a >> b;
    a *= b;
    cout << a << endl;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=998244353;

//status unsolved

//b^eを求める
long long  beki(long long  b, long long e)
{
    long long m=mod;
    long long ans = 1;

    while (e > 0) {
       if ((e & 1) == 1) ans = (ans * b) % m;
       e >>= 1;
       b = (b * b) % m;
    }

    return ans;
}
#define SIZE 200010
long long MOD=998244353;
using namespace std;
long long ans;

long long fac[SIZE],finv[SIZE],inv[SIZE];

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

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

int main(){
    long long n,m,k;
    cin>>n>>m>>k;

    long long ans=0;
    make();
    //被りの数で計算
    
    long long max_kaburi=k-1;
    /*
        nコのブロックのうち、
        同じ色で塗られているブロックの組み=kコの時
        左端の色の選び方=M
        左端以外のn-1個について、
        自身の左隣と同じものがkこ、
        そうでないものがn-1-k個存在する。

        前者の色の選び方は1通り
        後者の色の選び方はM-1通り、

        したがって、全てのk=0,1,2..Kについて
        M*C(n-1,k)*1^(k)*(n-1-k)^(M-1)通りあり、
        それを足し合わせる

    */
    for(long long i=0;i<=k;i++){
        long long a=C(n-1,i);
        long long b=beki(m-1,n-1-i);
        //cout<<a<<" "<<b<<" "<<i<<endl;
        long long total=(a*b)%mod;
        //total*=m;
        //total%=mod;
        total=(total*m)%mod;
        ans+=total;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;

}
/*

*/


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

int main() {
  int N, K, x, m, sum;
  sum = 0;
  cin >> N >> K;
  m = K/2;
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x <= m ) {
      sum += 2*x;
    }
    else {
      sum += (K-x)*2;
    }
  }
  
  cout << sum << endl;
}







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

using namespace std;

int main(void){

    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    
    double max = 0;
    int result1 = 100*a;
    int result2 = 0;
    
    for(int i=0; i<=30; i++) {
        if(i*a*100>f) continue;
        for(int j=0; j<=30; j++) {
            if(i*a*100+j*b*100>f) continue;
            for(int k=0; k<=3000; k++) {
                if(i*a*100+j*b*100+k*c>f) continue;
                for(int l=0; l<=3000; l++) {
                    if(i*a*100+j*b*100+k*c+l*d>f) continue;
                    if((i==0 && j==0) || (k==0 && l==0)) continue;

                    int water = i*a*100+j*b*100;
                    int suger = k*c+l*d;
                    
                    if((water/100)*e<suger) continue;
                    
                    double nodo = ((double)suger*100)/((double)water+(double)suger);
                    if( nodo>max ) {
                        max = nodo;
                        result1 = water+suger;
                        result2 = suger;
//                        cout << water << " " << suger << " " << max << endl;
                    }
                    
                }
            }
        }
    }
    
    cout << result1 << " " << result2 << endl;
//    cout << max << endl;
    
    return 0;
    
}


Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include <iomanip>
#include<queue>
#include<functional>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
int main() {
	int N, K; cin >> N >> K;
	long long int ans = 0;
	vector<ll> H(N);
	rep(i, N) {
		cin >> H[i];
	}
	sort(H.begin(), H.begin() + N, greater<int>());
	rep(i, N - K) {
		ans += H[i + K];
	}
	cout << ans << endl;

}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>

using namespace std;

struct Store {
	uint64_t price;
	uint64_t quantity;
};

int main() {
	uint64_t numofDrinks;
	uint64_t numofStores;
	vector<Store> storeinfo;

	scanf("%lld %lld", &numofStores, &numofDrinks);
	for (uint64_t i = 0; i < numofStores; ++i) {
		Store s;
		scanf("%lld %lld", &s.price, &s.quantity);
		storeinfo.push_back(s);
	}

	sort(
		storeinfo.begin(), storeinfo.end(), 
		[](Store l, Store r) { return l.price < r.price; }
	);

	uint64_t numofBought = 0;
	uint64_t moneys = 0;
	for (uint64_t si = 0; numofBought != numofDrinks; ) {
		if (storeinfo[si].quantity > 0) {
			moneys += storeinfo[si].price;
			storeinfo[si].quantity--;
			numofBought++;
		} else {
			si++;
		}
	}

	cout << moneys;

}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); i++)
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define j0 j5743892
#define j1 j542893
#define prev PREV
#define next NEXT
                         
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double D;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> T gcd(T a, T b) { re a ? gcd (b % a, a) : b; }
template<class T> T sqr(T a) { re a * a; }
template<class T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }

#define filename ""

int n;
int m;
string s;

int main () {
	cin >> s;
	int l = 0, r = sz (s) - 1, ans = 0;
	while (l < r) {
		if (s[l] != s[r]) {
			if (s[l] == 'x') { l++; ans++; } else
			if (s[r] == 'x') { r--; ans++; } else {
				printf ("-1\n");
				re 0;
			}
		} else {
			l++;
			r--;
		}
	}
	printf ("%d\n", ans);
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<pair<int, bool>> H(N, pair<int, bool>(0, true));
	REP(n, N) cin >> H[n].first;

	int A, B;
	REP(m, M) {
		cin >> A >> B;
		--A;
		--B;

		if (H[A].first <= H[B].first) H[A].second = false;
		if (H[B].first <= H[A].first) H[B].second = false;
	}

	int cnt = 0;
	REP(n, N) {
		if (H[n].second) ++cnt;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

namespace mp = boost::multiprecision;

mp::cpp_int gcd(mp::cpp_int a, mp::cpp_int b) {
  while (true) {
    if (a == 0) {
      return b;
    }
    b %= a;
    if (b == 0) {
      return a;
    }
    a %= b;
  }
}

mp::cpp_int lcm(mp::cpp_int a, mp::cpp_int b) {
  mp::cpp_int const temp = gcd(a, b);
  return temp ? (a / temp * b) : mp::cpp_int(0);
}

int calc(const std::vector<int>& as) {
  int ret = 0;
  mp::cpp_int x = 1;
  for (const auto& a : as) {
    x = lcm(x, static_cast<mp::cpp_int>(a));
  }
  x -= 1;
  for (const auto& a : as) {
    ret += static_cast<int>(x % static_cast<mp::cpp_int>(a));
  }
  return ret;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> as(n);
  for (auto& a : as) {
    std::cin >> a;
  }
  std::cout << calc(as) << std::endl;
  return 0;
}


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

struct Edge
{
    int to;
    int cost;
    ll time;
    Edge(int b, ll c, int d):
    to(b),cost(c), time(d){}
};

struct State
{
    int loc;
    ll sil;
    ll time;
    State(int l, ll s, ll t):
    loc(l), sil(s), time(t){}
};
bool operator<(const State& a, const State& b) {
  return a.time > b.time;
}

const ll INF = 10000000000000000;

int main()
{
    ll N, M, S;
    cin >> N >> M >> S;
    vector<vector<Edge>> edge(N, vector<Edge>());
    rep(i, 0, M)
    {
        ll U, V, A, B;
        cin >> U >> V >> A >> B;
        --U, --V;
        edge[U].emplace_back(V, A, B);
        edge[V].emplace_back(U, A, B);
    }
    vector<pair<ll, ll>> convert(N);
    rep(i, 0, N) cin >> convert[i].first >> convert[i].second;

    ll max_sil = 5000;
    priority_queue<State> que;
    vector<vector<ll>> dp(max_sil+1, vector<ll>(N, INF));
    que.emplace(0, min(S, max_sil), 0);
    while (que.size()>0)
    {

        State s = que.top();
        que.pop();
        // cout << "000" << endl;
        // cout << s.loc << ' ' << s.sil << ' '<< s.time << endl;

        if (dp[s.sil][s.loc]<=s.time) continue;
        dp[s.sil][s.loc] = s.time;

        // cout << s.loc << ' ' << s.sil << ' '<< s.time << endl;
        // ++dcnt;
        // if (dcnt == 2) break;

        // move to next city
        for (auto e: edge[s.loc])
        {
            // check avilability
            if (e.cost > s.sil) continue;
            que.emplace(e.to, s.sil-e.cost, s.time+e.time);
        }

        // convert money 
        int sil_cnt = s.sil + convert[s.loc].first;
        ll ctime = s.time + convert[s.loc].second;
        if  (sil_cnt < max_sil)
            que.emplace(s.loc, sil_cnt, ctime);
    }

    // print out result
    rep(i, 1, N)
    {
        ll min_time = INF;
        rep(c, 0, max_sil+1)
        {
            // cout << i << ' ' << c << ' ' << dp[c][i] << endl;
            min_time = min(min_time, dp[c][i]);
        }
        printf("%lld\n", min_time);
    }
    return 0;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, 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(12)

using namespace std;

typedef pair<int, int> P;

class CPoll {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        map<string, int> cnt;
        REP(i, N) {
            string s;
            cin >> s;
            cnt[s]++;
        }
        int m = 0;
        for (auto kv : cnt) {
            m = max(m, kv.second);
        }

        vector<string> res;
        for (auto kv : cnt) {
            if (kv.second == m) {
                res.push_back(kv.first);
            }
        }
        sort(res.begin(), res.end());
        for (auto& s : res) {
            cout << s << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CPoll solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 25584
N,W = map(int,input().rstrip().split(" "))
DP = [[-1 for _ in range(310)] for _ in range(N+1)]
DP[0][0] = 0
ans = 0
for i in range(N):
    w,v = map(int,input().rstrip().split(" "))
    if i == 0: w1 = w
    for i2 in range(i,-1,-1):
        for i3 in range(309,-1,-1):
            if DP[i2][i3] != -1:
                DP[i2 + 1][i3 + (w - w1)] = max(DP[i2 + 1][i3 + (w - w1)],DP[i2][i3]+v)
                if i2 * w1 + i3 + w <= W:
                    ans = max(DP[i2 + 1][i3 + (w - w1)],ans)
print(ans)

Measured memory_bytes: 74472
n = gets.to_i
a = gets.split.map(&:to_i)

total = a[0].abs

0.upto(n - 2) do |i|
  total += (a[i + 1] - a[i]).abs
end

total += a[-1].abs

a.unshift(0)
1.upto(n) do |i|
  if i == n
    cost = total - (a[i] - a[i - 1]).abs - (0 - a[i]).abs + (0 - a[i - 1]).abs
  else
    cost = total - (a[i] - a[i - 1]).abs - (a[i + 1] - a[i]).abs + (a[i + 1] - a[i - 1]).abs
  end
  puts cost
end

Measured memory_bytes: 12044
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			String str=sc.nextLine();
			char[] cPlaintext=str.toCharArray();
			String str1="abcdefghijklmnopqrstuvwxyz";
			char[] c1=str1.toCharArray();
			String str2="abcdefghijklmnopqrstuvwxyz";
			char[] c2=str2.toCharArray();
			char[] c3=new char[str.length()];
			boolean flag=false;
			while(true){
				for(int i=0;i<cPlaintext.length;i++){
					for(int j=0;j<c1.length;j++){
						if(cPlaintext[i]==c1[j]){
							c3[i]=c2[j];
							break;
						}else if(j==c1.length-1){
							c3[i]=cPlaintext[i];
						}
					}
				}
				for(int i=0;i<c3.length-3;i++){
					if(Character.toString(c3[i]).equals("t")&&Character.toString(c3[i+1]).equals("h")&&Character.toString(c3[i+2]).equals("e")){
						for(int j=0;j<c3.length;j++){
							System.out.print(c3[j]);
						}
						flag=true;
						break;
					}else if(i<c3.length-4&&Character.toString(c3[i]).equals("t")&&Character.toString(c3[i+1]).equals("h")){
						if(Character.toString(c3[i+2]).equals("i")&&Character.toString(c3[i+3]).equals("s")||Character.toString(c3[i+2]).equals("a")&&Character.toString(c3[i+3]).equals("t")){
							for(int j=0;j<c3.length;j++){
								System.out.print(c3[j]);
							}
							flag=true;
							break;
						}
					}
				}
				if(flag){
					System.out.println();
					break;
				}else{
					char box=c2[c2.length-1];
					for(int i=c2.length-1;i>0;i--){
						c2[i]=c2[i-1];
					}
					c2[0]=box;
				}
			}
		}
	}
}

Measured memory_bytes: 18988
#include <iostream>
using namespace std;
int main(){
  string S;
  string T;
  cin >> S >> T;
  int ans=0;
  int N= S.size();
  for(long long int i=0; i<N ; i++){
    if(S[i]!=T[i]){
      ans+=1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3812
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;

int main(){
  int X,Y;  cin >> X >> Y;
  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      if(2*i+4*j == Y && i+j == X){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int N; cin >> N&&N;) {
		int M; cin >> M;
		unordered_set<int> s;
		vector<int> a(M), b(M); rep(i, 0, M) { cin >> a[i] >> b[i]; }
		rep(i, 0, M) {
			if (a[i] == 1)s.insert(b[i]);
			else if (b[i] == 1)s.insert(a[i]);
		}
		vector<int> v;
		rep(i, 0, M) {
			if (s.count(a[i]))v.emplace_back(b[i]);
			else if (s.count(b[i]))v.emplace_back(a[i]);
		}
		rep(i, 0, v.size()) {
			s.insert(v[i]);
		}
		cout << s.size() - s.count(1) << endl;
	}
	return 0;
}

Measured memory_bytes: 3204
//
// Created by yamunaku on 2019/08/17.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int n;
    cin >> n;
    vl a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    queue<int> q, qq;
    rep(i,n){
        if(b[i] - b[(i+n-1)%n] - b[(i+1)%n] >= a[i]){
            q.push(i);
        }
    }
    ll ans = 0;
    while(!q.empty()){
        int now = q.front();
        q.pop();
        ll t=(b[(now+n-1)%n] + b[(now+1)%n]);
        ll k=(b[now]-a[now])/t;
        k=min(k,(b[now]-(b[(now+1)%n]-a[(now+1)%n]-b[(now+2)%n]))/t+1);
        k=min(k,(b[now]-(b[(now+n-1)%n]-a[(now+n-1)%n]-b[(now+n-2)%n]))/t+1);
        ans+=k;
        b[now] -= k*(b[(now+n-1)%n] + b[(now+1)%n]);
        qq.push(now);
        qq.push((now+n-1)%n);
        qq.push((now+1)%n);
        while(!qq.empty()){
            now = qq.front();
            qq.pop();
            if(b[now] - b[(now+n-1)%n] - b[(now+1)%n] >= a[now]){
                q.push(now);
            }
        }
    }
    rep(i, n){
        if(b[i] != a[i]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i ++) {
    cin >> a.at(i);
  }

  int count = n;
  for (int i = 0; i < n; i ++) {
    int tmp = a.at(i);
    while (d >= tmp + 1) {
      count ++;
      tmp += a.at(i);
    }
  }
  int ans = count + x;

  cout << ans << endl;
}


Measured memory_bytes: 256
/*
 * Matheus Oliveira
 * 09:03:52 01/09/2019
 * b.cpp
*/
#include <bits/stdc++.h>
using namespace std;

#define EPS
#define INF
#define MAXN
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define debug(x) printf("%s: %d\n", #x, x);
#define debugarr(x, ini, fim) printf("%s: ", #x); for(int i = ini; i <= fim; i++) printf("%d%c", x[i], (i == fim) ? '\n' : ' ');

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

int main() {
	int a, b, ans = 1;
	scanf("%d %d", &a, &b);

	if(b == 1) printf("0\n");
	else {
		int aux = a;
		while(a < b) {
			a = (a-1) + aux;
			ans++;
		}
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 256
// $%D%$.$%M%$.$%Y%$
// $%h%$:$%m%$:$%s%$

#pragma GCC optimize("O3")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define ld long double
#define rep(i,a,n) for (int i=(int)(a);i<(int)(n);i++)
#define per(i,a,n) for (int i=(int)(n-1);i>=(int)(a);i--)
#define mp(a, b) make_pair(a, b)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define fi first
#define se second


const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};


template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int main() {
    int x;
    cin >> x;
    cout << 1 - x << '\n';
}

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

int main() {
  int k,x;
  cin >> k >> x;
  for(int i = x-k+1;i <= x+k-1;i++){
    if (i != x+k-1){
      cout << i << ' ';
    }
    else{
      cout << i << endl;
    }
  }
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define MOD 1000000007LL
#define MX 5005

using namespace std;

typedef long long ll;

template <typename T> void read(T& x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

int n;
int fst[MX], nxt[MX*2], v[MX*2], lnum;
ll fac[MX], faci[MX], inv[MX];
int siz[MX], mxs[MX], cen, cnt;
int sbt[MX], sum[MX], snm;
ll f[MX][MX];

void addeg(int nu, int nv)
{
	nxt[++lnum] = fst[nu];
	fst[nu] = lnum;
	v[lnum] = nv;
}

void input()
{
	int a, b;
	read(n);
	for(int i=1; i<n; i++)
	{
		read(a); read(b);
		addeg(a, b);
		addeg(b, a);
	}
	fac[0] = faci[0] = inv[0] = inv[1] = 1;
	for(int i=2; i<=n; i++) inv[i] = (MOD - MOD/i) * inv[MOD%i] % MOD;
	for(int i=1; i<=n; i++) fac[i] = fac[i-1] * i % MOD, faci[i] = faci[i-1] * inv[i] % MOD;
}

void dfs(int x, int f)
{
	siz[x] = 1;
	for(int i=fst[x]; i; i=nxt[i])
	{
		if(v[i] != f)
		{
			dfs(v[i], x);
			siz[x] += siz[v[i]];
			mxs[x] = max(mxs[x], siz[v[i]]);
		}
	}
	mxs[x] = max(mxs[x], n-siz[x]);
	if(!cen || mxs[x]<mxs[cen]) cen = x, cnt = 1;
	else if(mxs[x] == mxs[cen]) cnt++;
}

void work()
{
	dfs(1, 0);
	assert(cnt <= 2);
	if(cnt > 1) sbt[1] = sbt[2] = n/2, snm = 2;
	else
	{
		for(int i=fst[cen]; i; i=nxt[i])
			if(siz[v[i]] < siz[cen])
				sbt[++snm] = siz[v[i]];
		sbt[++snm] = n-siz[cen];
	}
	sort(sbt+1, sbt+snm+1);
	f[0][0] = 1;
	for(int i=1; i<=snm; i++) sum[i] = sum[i-1] + sbt[i];
	for(int i=1; i<=snm; i++)
	{
		for(int j=0; j<=sum[i]; j++)
		{
			for(int k=0; k<=sbt[i]&&k<=j; k++)
			{
				ll f2 = fac[sbt[i]] * fac[sbt[i]] % MOD;
				ll d2 = faci[sbt[i]-k] * faci[sbt[i]-k] % MOD;
				ll d = faci[k] % MOD;
				f[i][j] = (f[i][j] + f[i-1][j-k] * f2 % MOD *d2 % MOD * d) % MOD;
			}
		}
	}
	ll ans = 0;
	for(int i=0; i<=n; i++)
		if(i & 1) ans = (ans + MOD*MOD - f[snm][i]*fac[n-i]) % MOD;
		else ans = (ans + f[snm][i]*fac[n-i]) % MOD;
	printf("%lld\n", ans);
}
int main()
{
	input();
	work();
	return 0;
}

Measured memory_bytes: 194176
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

#define ll long long

ll a[4] = {};
int main() {
	ll ans = 5;
	ll min = 0;
	ll n;
	cin >> n;
	
	for (ll i = 0; i < 5; i++)
	{
		cin >> a[i];
	}

	sort(a, a + 5);
	if (n > a[0]) {
		if (a[0] == 1) {
			ans = 4;
			min = n / a[0];
		}
		min = n / a[0];
	}

	cout << ans + min << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;

int main(void)
{
   int n,m;
   int i=0;
   int sum=0;
   double ave=0;
   while(scanf("%d,%d",&n,&m)!=EOF){
       sum+=n*m;
       ave+=m;
       i++;
   }
   int mean;
   mean=(int)(ave/i+0.5);
   cout<<sum<<endl;
   cout<<mean<<endl;
   return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} 



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

int N, R; cin >> N >> R;

if (N >= 10) cout << R << "\n";
else cout << R + 100 * (10 - N) << "\n";

return 0;
}
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 256
n=int(input())
l=[list(map(int,input().split())) for z in range(n)]
ans1=196471
for i in range(n):
    ans2=0
    y=l[i][0]
    m=l[i][1]
    d=l[i][2]
    ans2+=(y-1)*195+int((y-1)/3)*5
    if y%3==0:
        ans2+=(m-1)*20
    else:
        if (m-1)%2==0:
            ans2+=39*(m-1)/2
        else:
            ans2+=39*(m-2)/2+20
    ans2+=d
    print(int(ans1-ans2))


Measured memory_bytes: 5616
import java.util.*

fun main(args: Array<String>){

    var (N,M) = readLine()!!.split(" ").map{it.toInt()}

    var list = Array(N+1){ mutableListOf<Int>()}
    var P = IntArray(M)
    var Y = IntArray(M)

    for(i in 0 until M){
        var (p,y) = readLine()!!.split(" ").map{it.toInt()}
        P[i] = p
        Y[i] = y

        list[p].add(y)
    }

    for(i in 0..N){
        list[i].sort()
    }

    for(i in 0 until M){
        println("%06d".format(P[i]) + "%06d".format(list[P[i]].binarySearch(Y[i]) +1))
    }


}


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

int ary[40],ary2[1000010];
bool nopri[1000010];
int main(){
	int N;
	for(int i=1;i<=31;i++){
		cin>>ary[i];
		if(cin.eof()){
			N=i-1;
			break;
		}
	}

	int cnt=2;
	while(cnt<1000000){
		for(int i=2;i*cnt<1000000;i++){
			nopri[i*cnt]=true;
		}
		cnt++;
		while(nopri[cnt])cnt++;
	}
	cnt=0;
	for(int i=2;i<=1000000;i++){
		if(!nopri[i]) cnt++;
		ary2[i]=cnt;
	}
	for(int i=1;i<=N;i++){
		cout<<ary2[ary[i]]<<endl;
	}
	return 0;
}

Measured memory_bytes: 7880
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

string s;
int dy[4]={1,-1,0,0},dx[4]={0,0,1,-1};
bool f;

void dfs(int k,int y,int x){
	if(k==s.size()-1 || f){
		f=1; return;
	}
	rep(i,0,4){
		//int ny=(s[k]-'A')/3;
		//int nx=(s[k]-'A')%3;
		int ny=y+dy[i],nx=x+dx[i];
		if(ny<3 && ny>=0 && nx<3 && nx>=0){
			if('A'+ny*3+nx==s[k+1]){
				dfs(k+1,ny,nx);
			}
		}
	}

}

int main(){
	rep(i,0,1000){
		cin>>s;
		f=0;
		dfs(0,(s[0]-'A')/3,(s[0]-'A')%3);
		if(f) o(s);
	}
}

Measured memory_bytes: 1172
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;

void main()
{
    auto abc = readln.chomp.split.to!(int[]);
    if(abc[1] == abc[2])
        abc[0].writeln;
    else if(abc[0] == abc[2])
        abc[1].writeln;
    else
        abc[2].writeln;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
A = [["#"]*(w+2)] + [["#"] + [s for s in input()] + ["#"]
                     for _ in range(h)] + [["#"]*(w+2)]


def main():
    step = 0
    Q = set([])
    for hh in range(1, h + 1):
        for ww in range(1, w + 1):
            if A[hh][ww] == "#":
                if A[hh - 1][ww] == ".":
                    Q.add((hh - 1, ww))
                if A[hh][ww - 1] == ".":
                    Q.add((hh, ww - 1))
                if A[hh + 1][ww] == ".":
                    Q.add((hh + 1, ww))
                if A[hh][ww + 1] == ".":
                    Q.add((hh, ww + 1))
    while len(Q) > 0:
        step += 1
        new = set([])
        for hh, ww in Q:
            A[hh][ww] = "#"
        while len(Q) > 0:
            hh, ww = Q.pop()
            if A[hh - 1][ww] == ".":
                A[hh-1][ww] = "#"
                new.add((hh - 1, ww))
            if A[hh][ww - 1] == ".":
                A[hh][ww-1] = "#"
                new.add((hh, ww - 1))
            if A[hh + 1][ww] == ".":
                A[hh+1][ww] = "#"
                new.add((hh + 1, ww))
            if A[hh][ww + 1] == ".":
                A[hh][ww + 1] = "#"
                new.add((hh, ww + 1))
        Q = new.copy()
    print(step)
    return


if __name__ == "__main__":
    main()


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

int main(){
  string t;
  cin >> t;
  
  for(int i=0;i<t.size();i++){
    if(t.at(i)!='?') cout << t.at(i);
    else cout << "D";
  }
  cout << endl;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
const int MOD=1000000007;
const int INF=LLONG_MAX/2;
const int Maxa=200000;


signed main() {cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int k,x;
    cin>>k>>x;
    cout<<max({k+x,k-x,k*x})<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b){return *(int*)a-*(int*)b;}
int main(){
    int n, i =0;
    scanf("%d",&n);
    int a[n], b[n];
    for(; i < n; i++){
        scanf("%d",&a[i]);
        b[i] = a[i];
    }
    qsort(b,n,4,cmp);
    for(i = 0; i < n; i++){
        if(a[i] == b[n - 1])
            printf("%d\n",b[n - 2]);
        else
            printf("%d\n",b[n - 1]);
    }
    return 0;
}

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

int main() {
	
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	
	int mcost = INT_MAX;
	for (int med=0; med<=2*max(x, y); med+=2) {
		int mx = max(0, x - med / 2);
		int my = max(0, y - med / 2);
		mcost = min(mcost, mx * a + my * b + med * c);
		// cout << med << ' ' << mx * a + my * b + med * c << endl;
	}
	
	cout << mcost << endl;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
long long int adj[1000][1000];
long long int h[100000+10];
map<long long int,long long int>mp;
long long int val;
long long int answe1,res;
vector<lli>vect[400];
//set<lli>s;
/*void primeFactors(int n)
{
    // Print the number of 2s that divide n
    while (n % 2 == 0)
    {
        s.insert(2);
        n = n/2;
    }

    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            s.insert(i);
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        s.insert(n);
}
*/
int main()
{

    fast;


    lli n,m;
    cin>>n;
    lli INF=1e9+5;
    vector<lli>dp(3);

    vector<lli>c(3);
    for(lli days=0;days<n;days++)
    {

        vector<lli>newdp(3);
        for(lli i=0;i<3;i++)
        {
            cin>>c[i];
        }

        for(lli i=0;i<3;i++)
        {
            for(lli j=0;j<3;j++)
            {
                if(i!=j)
                {
                    newdp[j]=max(newdp[j],dp[i]+c[j]);
                }

            }
        }
        dp=newdp;

    }
    cout<<max({dp[0],dp[1],dp[2]});
    return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> a(N+1);
  rep (i, N) cin >> a[i+1];
  long ans = 0;
  for (long i = 1; i <= N; i++) {
    if (a[a[i]] == i) ans++;
  }
  cout << ans / 2 << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int main() {
  string S;
  cin >> S;
  string res = "Yes";
  for (int i = 0; i < S.size(); i++) {
    char temp = S.at(i);
    if ((i%2) == 0 ) {
      if ((temp != 'R') && (temp != 'U') && (temp != 'D') ){
        res = "No";
      }
    }
    else {
      if ((temp != 'L') && (temp != 'U') && (temp != 'D') ){
        res = "No";
      }
    }
  }
  cout << res << endl;
} 


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

int main(){
  while(1){
  vector<int> a;
  int n,k,m;
  cin>>n>>k>>m;
  if(n+k+m==0) break;
  for(int i=1;i<=n;i++)a.push_back(i);
  while(a.size()!=1) a.erase(a.begin()+m-1), m=(m+k-2)%a.size()+1;
    cout<<a[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1324
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: Mu-Chan
 *
 * Created on July 9, 2018, 6:18 PM
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct Node Node;

struct Node{
    int id;
    Node* parent;
    Node* sibling;
    Node* child;
};

typedef struct{
    Node *array;
}Tree;

void initNode(Node*);
void printTree(int,Node[]);
int getDepth(Node*);

int main(int argc, char** argv) {
    int size;
    scanf("%d\n", &size);
//    Tree tree;
    Node array[size];
    int loc, childNum, tempParent;
    int tempChild = -1;
    
    for(int i = 0; i < size; i++)
        initNode(&array[i]);
    
    for(int i = 0; i < size; i++){
        scanf("%d %d", &tempParent, &childNum);
        array[tempParent].id = tempParent;
        for(int j = 0; j < childNum; j++){
            scanf("%d", &loc);
            array[loc].parent = array+tempParent;
            if(j == 0)
                array[tempParent].child = array+loc;
            if(tempChild >= 0)
                array[tempChild].sibling = array+loc;
            tempChild = loc;
        }
        tempChild = -1;
    }
//    tree.array = array;
    printTree(size,array);
    
    return (EXIT_SUCCESS);
}

void initNode(Node *n){
    n->id = -1;
    n->child = NULL;
    n->sibling = NULL;
    n->parent = NULL;
}

void printTree(int size, Node tree[size]){
    int parent;
    char type[15];
    int temp;
    for(int i = 0; i < size; i++){
        printf("node %d: ", i);
        if(tree[i].parent == NULL)
            parent = -1;
        else
            parent = tree[i].parent->id;
        printf("parent = %d, ", parent);
        printf("depth = %d, ", getDepth(&tree[i]));
        if(tree[i].parent == NULL)
            strcpy(type,"root");
        else{
            if(tree[i].child != NULL)
                strcpy(type,"internal node");
            else
                strcpy(type,"leaf");
        }
        printf("%s, [", type);
        if(tree[i].child != NULL){
            temp = tree[i].child->id;
            printf("%d", temp);
            while(tree[temp].sibling != NULL){
                if(tree[temp].sibling != NULL)
                    printf(", ");
                temp = tree[temp].sibling->id;
                printf("%d", temp);
            }
        }
        printf("]\n");
    }
}

int getDepth(Node* target){
    int count = 0;
    if(target->parent != NULL){
        count++;
        count += getDepth(target->parent);
    }
    return count;
}



Measured memory_bytes: 4908
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define LL long long


int main() {
    int n;
    int max = 0;
    cin >> n;
    int total = 0;
    for (int i=0; i < n; i++) {
        int t;
        cin >> t;
        if (t >= max) {
            total++;
        }
        if (t > max) {
            max = t;
        }
    }

    cout << total << endl;
    return 0;
}

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

const int MOD=1e9+7;

int n,m,a[100001];
vector<int> v[100001];

inline int getlen(int i) {
    if(a[i]<=a[i+1]) return a[i+1]-a[i];
    else return m-a[i]+a[i+1];
}
bool isin(int l,int r,int x) {
    if(l<=r) return l<=x && x<=r;
    else return x>=l || x<=r;
}
int main() {
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%d",a+i),a[i]--;

    int cnt=0;
    lli sum=0,ans=10000000000000000ll;
    for(int i=1;i<n;i++) {
        if(a[i]==a[i+1]) continue;
        v[(a[i]+1)%m].push_back(i);
        v[(a[i+1]+1)%m].push_back(-i);
        
        if(!isin((a[i]+1)%m,(a[i+1])%m,m-1)) {
            sum += getlen(i);
        }else {
            if(a[i+1]!=m-1) sum += a[i+1];
            else sum--;
            cnt++;
        }
    }

    for(int i=0;i<m;i++) {
        for(auto &b:v[i]) {
            if(b<0) {
                cnt--; sum += getlen(-b)+1;
            } else {
                cnt++; sum -= 1;
            }
        }
        ans=min(ans,sum+cnt);
        sum -= cnt;
    }
    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 5376
#include<iostream>
#include<map>
#include<set>
using namespace std;

int main(){
    while(true){
        int n;
        cin >> n;
        if(n == 0)  break;

        map<string, int> table;

        string s;
        int p;

        for(int i = 0; i < n; i++){
            cin >> s >> p;
            table[s] = p;
        }

        int m;
        cin >> m;

        map<string, set<string>> recipe;
        for(int i = 0; i < m; i++){
            cin >> s >> p;
            string ingre;
            for(int i = 0; i < p; i++){
                cin >> ingre;
                recipe[s].insert(ingre);
            }
        }

        bool update = true;
        while(update){
            update = false;
            for(pair<string, set<string>> re : recipe){
                int cost = 0;
                bool judge = true;

                for(string x : re.second){
                    if(table.count(x) == 0){
                        judge = false;
                        break;
                    }
                    cost += table[x];
                }

                if(judge && 
                    (table.count(re.first) == 0 || table[re.first] > cost)){
                        update = true;
                        table[re.first] = cost;
                }

            }
        }

        string t;
        cin >> t;

        cout << table[t] << endl;
    }

    return 0;
}


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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  
  if (a >= b) cout << "delicious\n";
  else if (x+a >= b) cout << "safe\n";
  else cout << "dangerous\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <numeric>
#include <ios> // std::left, std::right

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

int main()
{
  int a, b, t;
  cin >> a >> b >> t;
  cout << (t / a) * b << endl;

  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define MAX (ll)(1e6 + 7)
#define INF (ll)(1e18 + 7)
#define MOD (ll)(1e9 + 7)

using namespace std;
using ll = long long;
using cd = complex<double>;

int main () {
	int x ;
	cin >> x;
	x ^= 1;
	cout << x << "\n";
}


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

const int MAXN = 100100;
int n;
int h[MAXN];
long long int dp[MAXN];


int main() {

  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &h[i]);
  }
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < n; i++) {
    dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2]);
  }
  cout << dp[n - 1];

}


Measured memory_bytes: 1408
//*INDENT-OFF*
#include<bits/stdc++.h>
using namespace std;
template<typename V>
bool tomin(V&x,V y){if(y<x){x=y;return true;}return false;}
template<typename V>
bool tomax(V&x,V y){if(x<y){x=y;return true;}return false;}
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
#pragma GCC optimize(3)
#define lowbit(x) ((x)&-(x))
//*INDENT-ON*
int main(){
    ll n,d;
    cin>>n>>d;
    cout<<ceil(n/(double)(d+d+1))<<endl;
    return 0;
}

Measured memory_bytes: 256