akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define INF 1e18
#define MAX_V 1002

struct edge{int to; double cost;};
typedef pair<double,int> P;

int V;
vector<edge> G[MAX_V];
double d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0,s));

    while(!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(edge e : G[v]) {
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

double dist(double x1, double y1, double x2, double y2) {
    return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}

int main() {
    double xs, ys, xt, yt;
    int N;
    vector<double> x(2), y(2), r(2);
    cin >> x[0] >> y[0] >> x[1] >> y[1];
    r[0] = r[1] = 0.0;
    cin >> N;
    x.resize(N+2); y.resize(N+2); r.resize(N+2);
    for(int i=2; i<N+2; ++i) cin >> x[i] >> y[i] >> r[i];
    V = N + 2;

    for(int i=0; i<V; ++i) {
        for(int j=0; j<V; ++j) {
            if(i == j) continue;
            G[i].push_back({j, max(0.0, dist(x[i], y[i], x[j], y[j]) - r[i] - r[j])});
        }
    }

    dijkstra(0);
    cout << fixed << setprecision(10);
    cout << d[1] << endl;
}

Measured memory_bytes: 22256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n; cin >> n;
  string s; cin >> s;
  vector<ll> cntE(n + 1), cntW(n + 1);
  for (int i = 1; i <= n; i++) {
    cntE[i] = cntE[i - 1];
    cntW[i] = cntW[i - 1];

    if (s[i-1]=='E') cntE[i]++;
    else cntW[i]++;
  }
  ll ans = __INT_MAX__;

  for (int i = 0; i < n; i++) {
    ll lv = cntW[i];
    ll rv = cntE[n] - cntE[i+1];
    // debug2(lv, rv);
    ans = min(ans, lv + rv);
  }

  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 5372
#include<bits/stdc++.h>
using namespace std;
vector<int>uni;
int root(int v) {
  if (v == uni[v]) return v;
  return uni[v] = root(uni[v]);
}
void unit(int a, int b) {
  a = root(a);
  b = root(b);
  if (a == b) return;
  uni[b] = a;
}
int main () {
  int N;
  cin >> N;
  uni.resize(N);
  for (int i = 0; i < N; i ++) uni[i] = i;
  int M;
  cin >> M;
  vector<int>P(N);
  vector<int>P_f(N);
  for (int i = 0; i < N; i ++) {
    int p;
    cin >> p;
    p --;
    P[i] = p;
    P_f[p] = i;
  }
  for (int i = 0; i < M; i ++) {
    int x, y;
    cin >> x >> y;
    x --;
    y --;
    unit(x, y);
  }
  int ans = 0;
  for (int i = 0; i < N; i ++) {
    if (root(i) == root(P_f[i])) ans ++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int i;
    string s;
    cin>>s;
    if((s[0]==s[1] && s[2]==s[3] &&s[0]!=s[2]) || (s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]) || (s[0]==s[3]&& s[1]==s[2] && s[0]!=s[2]))
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

}


Measured memory_bytes: 256
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Sat Dec 22 01:53:10 2018
//
package main

import "fmt"

type line struct {
	from, to, weight int
}

func pow2(n int) int {
	if n == 0 {
		return 1
	}
	return 2 * pow2(n-1)
}

func div2Count(n int) int {
	ans := 0
	for n > 1 {
		n /= 2
		ans++
	}
	return ans
}

func main() {
	var L int
	fmt.Scan(&L)

	n := div2Count(L) + 1
	lines := make([]line, 0)
	for i := 0; i < n; i++ {
		if i+1 < n {
			lines = append(lines, line{from: i + 1, to: i + 2, weight: 0})
			lines = append(lines, line{from: i + 1, to: i + 2, weight: pow2(i)})
		}
	}

	rem := L - pow2(n-1)
	weight := pow2(n - 1)
	for rem > 0 {
		a := div2Count(rem)
		rem -= pow2(a)
		lines = append(lines, line{from: a + 1, to: n, weight: weight})
		weight += pow2(a)
	}

	fmt.Println(n, len(lines))
	for _, l := range lines {
		fmt.Println(l.from, l.to, l.weight)
	}
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ci cin >>
#define co cout <<

int main() {
	bool E = true;
	int A, B, C, D;
	ci A >> B >> C >> D;
	if (abs(B - A) > D || abs(C - B) > D) E = false;
	if (abs(C - A) <= D)E = true;
	if (E)co "Yes";
	else co"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
const int N = 1e6 + 10;
int n, ans; char s[N], t[N];
deque <int> Q;

inline int check() {
	for (int i = n, p = n; i; --i) {
		if (t[i] == t[i - 1]) continue;

		p = min(p, i);
		for (; p && s[p] != t[i]; --p);
		if (!p) return 0;

		for (;!Q.empty();) {
			int x = Q.back(), sz = Q.size();
			if (x >= i + sz) Q.pop_back();
			else break;
		}
		Q.push_front(p);
		if (i != p) ans = max(ans, (int)Q.size());
	}
}

int main() {
	scanf("%d", &n);
	scanf("%s%s", s + 1, t + 1);

	if (!strcmp(s + 1, t + 1)) return puts("0"), 0;
	if (!check()) return puts("-1"), 0;
	printf("%d\n", ans + 1);
	return 0;
}

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

int main() {
    long long n;
    set<string> s;
    string tmp;
    cin >> n;
    for (long long i = 0; i < n; i++) {
        cin >> tmp;
        s.insert(tmp);
    }

    cout << s.size() << endl;
}


Measured memory_bytes: 19228
#include <iostream>                                                  
using namespace std;                                                 
                                                                     
int main() {                                                         
  while (true) {                                                     
    int n;                                                           
    cin >> n;                                                        
    if (n==0) {                                                      
      break;                                                         
    }                                                                
    int A, B;                                                        
    int Ascore = 0, Bscore = 0;                                      
    for (int i=0; i<n; i++) {                                        
      cin >> A >> B;                                                 
      if (A>B) {                                                     
        Ascore += (A+B);                                             
      } else if (B>A) {                                              
        Bscore += (A+B);                                             
      } else {                                                       
        Ascore += A;                                                 
        Bscore += B;                                                 
      }                                                              
    }                                                                
    cout << Ascore << " " << Bscore << endl;                         
  }                                                                  
  return 0;                                                          
}                          

Measured memory_bytes: 3052
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000001ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.14159265358979323

int main() 
{
    FAST;
    ll n,b;
    cin>>n;
    b=ceil(n/2.0);
    double ans=b/(double)n;
    cout<<fixed<<setprecision(6)<<ans;
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int c[26][2];

int depth(int i,int h){
  int l=0,r=0,m;
  if(c[i][0]!=-1){
    l=depth(c[i][0],h);
  }
  if(c[i][1]!=-1){
    r=depth(c[i][1],h);
  }
  if(l+1>r+1)m=l+1;
  else m=r+1;
  return m;
}

int main(){
  int p[25],id,n,a,b,d;
  cin>>n;
  for(int i=0;i<n;i++)p[i]=-1;
  for(int i=0;i<n;i++){
    cin>>a>>b>>d;
    if(b!=-1)p[b]=a;
    if(d!=-1)p[d]=a;
    c[a][0]=b;
    c[a][1]=d;
  }
  int k,cn=0,de,h=0;
  for(int i=0;i<n;i++){
    cout<<"node "<<i;
    cout<<": parent = "<<p[i];
    
    cout<<", sibling = ";
    if(p[i]==-1)cout<<"-1";
    else if(c[p[i]][0]!=i)cout<<c[p[i]][0];
    else if(c[p[i]][1]!=i)cout<<c[p[i]][1];
    
    cout<<", degree = ";
    if(c[i][0]!=-1&&c[i][1]!=-1){
      cout<<2;
      cn=2;
    }else if(c[i][0]==-1&&c[i][1]==-1){
      cout<<0;
      cn=0;
    }else cout<<1;cn=1;
    
    cout<<", depth = ";
    de=0;
    h=i;
    while(p[h]!=-1){
      h=p[h];
      de++;
    }
    cout<<de;
    h=0;
    cout<<", height = ";
    h=depth(i,0);
    cout<<h-1;//////
    if(de==0)cout<<", root"<<endl;
    else if(c[i][0]==-1&&c[i][1]==-1)cout<<", leaf"<<endl;
    else cout<<", internal node"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1168
_input = input
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

#ここに書きたいコードを書く
#データ読み込み

N=int(input())
S=input()

RGB_num=[0]*3

for c in S:
	if c=='R':
		RGB_num[0] += 1
	elif c=='G':
		RGB_num[1] += 1
	else:
		RGB_num[2] += 1

#print(RGB_num)
joken2=0

for i in range(N-2):
	#print("i",i,S[i+1])
	for j in range(min(i+1,N-i-2)):
		if S[i+1] != S[i-j] and S[i+1] != S[i+j+2] and S[i-j] != S[i+j+2]:
			joken2 += 1
			#print(i,j,S[i-j]+S[i+1]+S[i+j+2],"j2")
		#else:
			#print(i,j,S[i-j]+S[i+1]+S[i+j+2])

joken1=RGB_num[0]*RGB_num[1]*RGB_num[2]

print(joken1-joken2)

input = _input


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

const int MAXN = 200005;

int a[MAXN], p[MAXN];

int main() {

  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> a[i]; p[a[i]] = i;
  }

  int longest_consecutive = 1, cur_max = 1;
  for (int i = 1; i < N; i++) {
    if (p[i+1] > p[i]) {
      cur_max++;
    } else {
      longest_consecutive = max(longest_consecutive, cur_max);
      cur_max = 1;
    }
  }

  longest_consecutive = max(longest_consecutive, cur_max);

  cout << N - longest_consecutive << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	string S, T;
	cin >> S >> T;
	for (int i = 0; S[i]; i++)
	{
		if (S[i] != T[i])
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}



Measured memory_bytes: 3628
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

let main() =
    let h = read int64

    // 2^n <= h <= 2^(n+1) - 1 にあるとき、答えは 2^(n+1) - 1
    let mutable (ok, ng) = (64, -1)
    while abs (ok - ng) > 1 do
        let mid = (ok + ng) / 2
        let a = pown 2L mid
        if h < a then ok <- mid else ng <- mid

    let ans = (pown 2L ok) - 1L
    ans |> puts
    ()

main()
writer.Close()


Measured memory_bytes: 11220
N = int(input())
A = [int(x) for x in input().split()]

sums = [0] * N
sums[0] = A[0]
for i in range(N - 1):
    sums[i + 1] = sums[i] + A[i + 1]  # sums[i] stores the sum of A0~Ai

sum = 0
for i in range(N):
    sum += A[i] * (sums[N-1] - sums[i])

print(sum % 1000000007)

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

vector<vector<int>> G;
vector<int> color;

bool dfs(int v, int c){
    color[v] = c;
    for (int i = 0; i < G[v].size(); ++i) {
        int nv = G[v][i];
        if(color[nv] == c) return false;
        if(color[nv] == -1 && !dfs(nv, (c+1) % 2)) return false;
    }
    return true;
}

int main(){
    ll n, m;
    cin >> n >> m;
    G.assign(n, vector<int>());
    int a, b;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    color.assign(n, -1);

    if(dfs(0, 0)){
        ll white = 0;
        ll black = 0;
        for (int i = 0; i < n; ++i) {
            if(color[i]) white++;
            else black++;
        }
        cout << white * black - m << endl;
    }
    else cout << n * (n-1) / 2 - m << endl;
}

Measured memory_bytes: 6528
#include <cstdio>
#include <algorithm>

using namespace std;

long long calc(long long n, long long a, long long b) {
    if ((b - a) % 2 == 0) {
        return (b - a) / 2;
    } else if (a == 1 || b == n) {
        return (b - a + 1) / 2;
    } else {
        return min(calc(n, 1, b - a + 1) + a - 1, calc(n, a + n - b, n) + n - b);
    }
}

int main() {
    long long n, a, b;
    
    scanf("%lld %lld %lld", &n, &a, &b);
    
    printf("%lld\n", calc(n, a, b));
    
    return 0;
}


Measured memory_bytes: 128
//author Forsaken
#define Hello the_cruel_world!
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<numeric>
#define max(x,y) ((x) > (y) ? (x) : (y))
#define min(x,y) ((x) < (y) ? (x) : (y))
#define lowbit(x) ((x) & (-(x)))
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\1.in", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\1.out", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define outd(x) printf("%d\n", x)
#define outld(x) printf("%lld\n", x)
#define memset0(arr) memset(arr, 0, sizeof(arr))
#define il inline
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 1e5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
const double eps = 1e-7;
const double Pi = acos(-1.0);
il int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll quick_pow(ll base, ll index, ll p) {
	ll res = 1;
	while (index) {
		if (index & 1)res = res * base % p;
		base = base * base % p;
		index >>= 1;
	}
	return res;
}
int arr[maxn + 5], n, res;
int main()
{
	n = read_int();
	for (int i = 1; i <= n; ++i)arr[i] = read_int();
	for (int i = 2; i < n; ++i) {
		int u = arr[i], a = max(arr[i - 1], arr[i + 1]), b = min(arr[i - 1], arr[i + 1]);
		if (u < a && u > b)++res;
	}
	outd(res);
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;


vector<int>  dx = {1,-1,0,0};
vector<int>  dy = {0,0,1,-1};


int main() {
	int H,W; cin >> H >> W;

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

	int cnt = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (A[i][j] == '#') {
				cnt++;
			}
		}
	}

	if (H + W - 1 == cnt ) {
		cout << "Possible" << endl;
	}else {
		cout << "Impossible" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

int main(){
    long double N;
    cin>>N;
    long double P=3.14159265;
    cout<<N*P*2<<endl;
}

Measured memory_bytes: 3792
import numpy as np

input_line_count = input()
line_count = int(input_line_count)

line = np.zeros([line_count, 3])
line_check = np.zeros(line_count)
for num in range(line_count):
  input_line = input()
  line[num] = input_line.split()
  if(line[num][0] % 2 == 0):
    if((line[num][1] + line[num][2]) % 2 == 0 and (line[num][1] + line[num][2]) <= line[num][0]):
      line_check[num] = 1
  elif(line[num][0] % 2 == 1):
    if((line[num][1] + line[num][2]) % 2 == 1 and (line[num][1] + line[num][2]) <= line[num][0]):
      line_check[num] = 1
for num1 in range(line_count):
  if(line_check[num1] == 0):
    answer = "No"
    break
  else:
    answer = "Yes"

print(answer)


Measured memory_bytes: 15592
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long li;

bool Solve(li a, li b, li c, li d) {
  if (a < b) return 0;
  if (b > d) return 0;
  if (c >= b) return 1;
  li g = __gcd(b, d);
  li x = (a - c - 1) / g;
  li y = (a - b) / g;
  if (x > y) return 0;
  return 1;
}

int main(void) {
  int cas;
  scanf("%d", &cas);
  while (cas--) {
    li a, b, c, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    if (Solve(a, b, c, d)) puts("Yes");
    else puts("No");
  }

  return 0;
}


Measured memory_bytes: 128
from collections import deque
import collections

mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

X,K,D = MI()
flag = 1
if(X<0):
  flag = -1

n = int(X/D)
if(abs(n) < K):
  X = X - n*D
  K = K - n
else:
  X = X - K*D*flag
  print(abs(X))
  exit()

if(K%2==0):
  print(abs(X))
else:
  print(abs(X-D*flag))



Measured memory_bytes: 9412
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

int main(void) {
    int d;
    cin >> d;
    if ( d == 25) {

        cout << "Christmas" << endl;

    } else if (d==24) {
        cout << "Christmas Eve" << endl;

    } else if (d==23) {
        cout << "Christmas Eve Eve" << endl;

    } else {
        cout << "Christmas Eve Eve Eve" << endl;
    }

    return 0;
}

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

col=[x]
sude=[0]*m
sude[x]=1
now=x
ishu=0
hajimari=0
for i in range(m):
    now**=2
    now%=m
    #print(now)
    if(sude[now]==0):
        sude[now]=i+2
        col.append(now)
    else:
        ishu=i-sude[now]+2
        hajimari=sude[now]-1
        break


#print(ishu,hajimari,col)

saisho=0
loop=0
for i in range(hajimari):
    saisho+=col[i]
for i in range(hajimari,len(col)):
    loop+=col[i]

#print(saisho,loop)

ans=0

if(n<hajimari):
    ans+=col[i]
else:
    ans=saisho+loop*((n-hajimari)//ishu)
    nokori=n-hajimari-ishu*((n-hajimari)//ishu)
    for i in range(hajimari,hajimari+nokori):
        ans+=col[i]

print(ans)

Measured memory_bytes: 71408
#include<iostream>

using namespace std;

int N, M, Q;

int ar[500][500], ruisekiwa[501][501];

int main() {
	cin >> N >> M >> Q;
	for (int i = 0; i < M; i++) {
		int l, r;
		cin >> l >> r;
		l--, r--;
		ar[l][r]++;
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++)
			ruisekiwa[i][j] = ruisekiwa[i - 1][j] + ar[i - 1][j - 1];
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++)
			ruisekiwa[j][i] += ruisekiwa[j][i - 1];
	}


	for (int i = 0; i < Q; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		cout << ruisekiwa[b + 1][b + 1] - ruisekiwa[a][b + 1] - ruisekiwa[b + 1][a] + ruisekiwa[a][a] << endl;
	}

	return 0;
}

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

	public static void main(String[] args) {
		Scanner seer = new Scanner(System.in);
		int n = seer.nextInt();
		int[] arr = new int[n];
		for(int i = 0; i < n; i++){
			arr[i] = seer.nextInt();
		}
		int mincost = Integer.MAX_VALUE;
		for(int val = -100; val <= 100; val++){
			int cost = 0;
			for(int k: arr){
				cost += (k - val)*(k - val);
			}
			mincost = Integer.min(mincost, cost);
		}
		System.out.println(mincost);
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>



using ll = long long;


using namespace std;
int gcd(int a, int b) {
	if (a < b) {
		int t = a;
		a = b;
		b = t;
	}
	
	while (b != 0) {
		int t = b;
		b = a % b;
		a = t;
	}
	return a;
}

int factorial(ll n) {
	if (n > 0) {
		return n * factorial(n - 1);
	}
	else
		return 1;
}
int main()
{/*12日目*/
	string s; cin >> s;
	cout << s[0] << s[1] << s[2];
}
	

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
ll factorial[200001];
ll factorialinv[200001];
ll calc(ll a,ll b,ll c){
  if(b==0)return 1;
  else if(b%2==0){
    ll d=calc(a,b/2,c);
    return d*d%c;
  }
  else {
    return a*calc(a,b-1,c)%c;
  }
}
ll combi(ll a, ll b){
  return factorial[a]%mod*factorialinv[b]%mod*factorialinv[a-b]%mod;
}
int main(){
 long long int n,m,k,ans=0;
  cin >> n >>m >>k;
  factorial[0]=1;
  factorialinv[0]=1;
  for(ll i=1;i<=n;i++){
    factorial[i]=factorial[i-1]*i%mod;
    factorialinv[i]=factorialinv[i-1]*calc(i,mod-2,mod)%mod;
  }
  ll waru[n];
  ll temp;
  waru[0]=1;
  for(long long int i=1;i<n;i++)waru[i]=(waru[i-1]*(m-1))%mod;
  for(long long int i=n-1;i>=max(n-k-1,(long long)0);i--){
    temp=waru[i]*m%mod*combi(n-1,i); 
    cerr << temp;
    ans=(ans+temp)%mod;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 8568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, a;
int main()
{
    cin.sync_with_stdio(0); cin.tie(0);
    for(int i = 1,t; i <= 5; i++){
        cin >> t;
        if(t == 0){
            a = i;
        }
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 3600
//**************************
//*** writer  :  Alex Hu **
//************************

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
const int maxn=100005,maxd=11;
int c[maxn][maxd];
int col[maxn];
vector<int> e[maxn];
 
int main(){
 
	int n,m,q;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		--a;--b;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	cin>>q;
	for(int i=0;i<q;i++){
		int v,d;
		cin>>v>>d>>col[i+1];
		--v;
		c[v][d]=i+1;
	}
	for(int i=maxd-2;i>=0;i--){
		for(int v=0;v<n;v++){
			for(int u=0;u<e[v].size();u++){
				c[e[v][u]][i]=max(c[e[v][u]][i],c[v][i+1]);
			}
		}
	}
	for(int v=0;v<n;v++){
		int res=0;
		for(int d=0;d<maxd;d++){
			res=max(res,c[v][d]);
		}
		cout<<col[res]<<endl;
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 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)

typedef long long LL;
typedef long double LD;



int main(){
  int h,w;
  cin >> h >> w;
  vector<string> f(h);
  queue<pair<pair<int,int>,int>> q;
  vector<vector<bool>> visited(h,vector<bool>(w,false));
  int sx,sy,gx,gy;
  rep(i,h){
    cin >> f[i];
    rep(j,w){
      if(f[i][j]=='@'){
        sx=i,sy=j;
        f[i][j]='.';
      }else if(f[i][j]=='$'){
        q.push({{i,j},0});
        visited[i][j]=true;
        f[i][j]='.';
      }else if(f[i][j]=='%'){
        gx=i,gy=j;
        f[i][j]='.';
      }
    }
  }
  vector<int> v={0,1,0,-1,0};
  int gd=IINF;
  while(!q.empty()){
    auto now = q.front();
    q.pop();
    rep(i,4){
      int nx = now.first.first+v[i];
      int ny = now.first.second+v[i+1];
      if(0<=nx&&nx<h&&0<=ny&&ny<w){
        if(f[nx][ny]=='.'&&!visited[nx][ny]){
          visited[nx][ny]=true;
          if(nx==gx&&ny==gy){
            gd=now.second+1;
            goto next;
          }
          q.push({{nx,ny},now.second+1});
        }
      }
    }
  }
  next:;
  while(!q.empty()) q.pop();
  visited=vector<vector<bool>>(h,vector<bool>(w,false));
  q.push({{sx,sy},0});
  while(!q.empty()){
    auto now = q.front();
    q.pop();
    rep(i,4){
      int nx = now.first.first+v[i];
      int ny = now.first.second+v[i+1];
      if(0<=nx&&nx<h&&0<=ny&&ny<w){
        if(f[nx][ny]=='.'&&!visited[nx][ny]){
          visited[nx][ny]=true;
          if(nx==gx&&ny==gy){
            if(now.second+1<gd){
              CYES;
            }else{
              CNO;
            }
            return 0;
          }
          q.push({{nx,ny},now.second+1});
        }
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3520
import java.io.*;
        import java.util.*;
        public class Main{
          public static void main(String[] args) throws IOException{
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            int N = Integer.parseInt(reader.readLine());
            int K = Integer.parseInt(reader.readLine());
            int X = Integer.parseInt(reader.readLine());
            int Y = Integer.parseInt(reader.readLine());
            if((N-K)>0) System.out.println(K*X+(N-K)*Y);
            else System.out.println(N*X);
          }}

Measured memory_bytes: 21204
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n, y, b;
    int ansB;
    double max;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    if(n==0) break;
	    y = sc.nextInt();
	    ansB = -1; max = 0;

	    for(int i=0; i<n; i++){
		b = sc.nextInt();
		double money = getMoney(sc.nextDouble(), sc.nextInt());
		if(money > max){
		    max = money;
		    ansB = b;
		}
		//System.out.println(money);
	    }

	    System.out.println(ansB);
	}
    }

    double getMoney(double r, int t){
	if(t==1)
	    return 1+y*r/100;
	else
	    return getP(1+r/100, y);
    }

    double getP(double a, int x){
	if(x==1)
	    return a;
	double z = getP(a, x/2);
	if(x%2==0)	    
	    return z*z;
	else 
	    return z*z*getP(a, 1);
    }
}

Measured memory_bytes: 50348
import sys
input = sys.stdin.readline

n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

ans = 10**20

for i in range(n):
    temp = abs(a - (t - h[i] * 0.006))
    if ans > temp:
        ans = min(ans, temp)
        cnt = i + 1

print(cnt)


Measured memory_bytes: 3060
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll L, R;
  cin >> L >> R;
  if(R-L>=2019){
    cout << 0;
  }else{
    ll ans = 100000;
    for(ll i = L;i<R;i++){
      for(ll j=i+1;j<=R;j++){
        ans = min(ans, (i*j)%2019);
      }
    }
    cout << ans;
  }

  return 0;
}


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

using namespace std;
int main() {
	int n, k; cin >> n >> k;
	vector<int>a(n); for (int i = 0; i < n; i++)cin >> a[i];
	vector<bool>dp(k + 1, false);
	for (int i = 0; i <= k; i++) {
		bool found = false;
		for (int j = 0; j < n && a[j] <= i; j++) {
			if (!dp[i - a[j]]) found = true;
		}
		dp[i] = found;
	}
	cout << (dp[k] ? "First" : "Second") << endl;
	return 0;
}

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

typedef long long int ll;

int main()
{
	ll n;
	scanf("%lld",&n);
	ll a=n%10;
	if(n%10==3)
		printf("bon\n");
	else if(a==0 || a==1 || a==6 || a==8)
		printf("pon\n");
	else
		printf("hon\n");
}


Measured memory_bytes: 3764
//coded by not_surrender

#include <bits/stdc++.h>

#define MAXN 100010
#define mid ((a+b)/2)
#define L (nod*2)
#define R (nod*2+1)
#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef vector <int> vi;

int main(){

	//~ freopen( "a.txt", "r", stdin );
	
	ios_base::sync_with_stdio( false );
	cin.tie( NULL ), cout.tie( NULL );
	
	string S;
	
	cin >> S;
	
	for ( int i = 0; i < S.size()-1; ++i )
		if ( S[i] == S[i+1] )
			return !(cout << i+1 << ' ' << i+2 << '\n');
	
	for ( int i = 0; i < S.size()-2; ++i )
		if ( S[i] == S[i+2] )
			return !(cout << i+1 << ' ' << i+3 << '\n');
	
	cout << "-1 -1\n";

return 0;	
}


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

using namespace std;

#define mod 1000000007
#define int long long int
#define pii pair<int,int>
#define vpii vector<pii>
#define vi vector<int>
#define fi first
#define se second
#define psb push_back
#define ppb pop_back
#define fio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define all(x) x.begin(),x.end()

const int maxv=1e18;
int ar[100005];

int32_t main()
{
	int n;
	cin>>n;
	int flag=0;
	for(int i=0;i<n;i++)
	{
		cin>>ar[i];
		if(ar[i]==0)
			flag=1;
	}
	if(flag)
	{
		cout<<0<<endl;
		return 0;
	}
	flag=0;
	int p=1;
	for(int i=0;i<n;i++)
	{
		if(p>maxv/ar[i])
		{
			flag=1;
			break;
		}
		p*=ar[i];
	}
	cout<<(flag?-1:p)<<endl;
}

Measured memory_bytes: 4416
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class mint:
    def __init__(self, x):
        self.__x = x % md

    def __str__(self):
        return str(self.__x)

    def __add__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x + other)

    def __sub__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x - other)

    def __rsub__(self, other):
        return mint(other - self.__x)

    def __mul__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * other)

    __radd__ = __add__
    __rmul__ = __mul__

    def __truediv__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * pow(other, md - 2, md))

    def __pow__(self, power, modulo=None):
        return mint(pow(self.__x, power, md))

def nCr(com_n, com_r):
    if com_n < com_r: return 0
    return fac[com_n] * ifac[com_r] * ifac[com_n - com_r]

def s(r, c):
    return nCr(r + c + 2, r + 1)

r1, c1, r2, c2 = MI()
md = 10**9+7
n_max = r2+c2+5
fac = [mint(1)]
for i in range(1, n_max + 1): fac.append(fac[-1] * i)
ifac = [1] * (n_max + 1)
ifac[n_max] = fac[n_max] ** (md - 2)
for i in range(n_max - 1, 1, -1): ifac[i] = ifac[i + 1] * (i + 1)

def main():
    ans=s(r2,c2)-s(r1-1,c2)-s(r2,c1-1)+s(r1-1,c1-1)
    print(ans)

main()

Measured memory_bytes: 399224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = long.Parse(Console.ReadLine());
			var aList = Console.ReadLine().Split(' ').Select(value => long.Parse(value)).ToList();

			if (aList[0] == 0)
			{
				var min = long.MaxValue;
				aList[0] = 1;
				min = Math.Min(Sequence(aList), min);
				aList[0] = -1;
				min = Math.Min(Sequence(aList), min);

				Console.WriteLine(min + 1);
			}
			else
			{
				var min = long.MaxValue;
				min = Math.Min(Sequence(aList), min);

				long tmp;
				if(aList[0] > 0)
				{
					tmp = aList[0] + 1;
					aList[0] = -1;
				}
				else
				{
					tmp = -aList[0] + 1;
					aList[0] = 1;
				}
				min = Math.Min(Sequence(aList) + tmp, min);

				Console.WriteLine(min);
			}
		}

		private static long Sequence(List<long> list)
		{
			long sum = list[0];
			var isPreviousSumPositive = list[0] > 0;
			long count = 0;

			for (var i = 1; i < list.Count; i++)
			{
				sum += list[i];
				if (isPreviousSumPositive && sum >= 0)
				{
					count += sum + 1;
					sum = -1;
				}
				else if (!isPreviousSumPositive && sum <= 0)
				{
					count += -sum + 1;
					sum = 1;
				}

				if (sum > 0)
				{
					isPreviousSumPositive = true;
				}
				else
				{
					isPreviousSumPositive = false;
				}
			}

			return count;
		}
	}
}


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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define FST1 cin.tie(0)
#define FST2 ios::sync_with_stdio(false)

int n,a,b;
string s;

int main() {
    FST1; FST2;
    cin>>n>>a>>b;
    cin>>s;
    int c = a+b;

    int p=0, q=0;
    rep(i,n) {
        bool f = false;
        if(s[i]=='a'){
            if(p < c) {
                f = true;
            }
            p++;
        }else if(s[i]=='b'){
            q++;
            if(p<c and q<=b) {
                f = true;
                p++;
            }
        }
        cout << (f ? "Yes" : "No") << endl;
    }


    return 0;
}

Measured memory_bytes: 848
package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scanf("%d %d\n", &N, &M)
	A := make(map[int]bool)
	answer := make([]int, N+1, N+1)
	for i := 0; i < M; i++ {
		var a int = -1
		fmt.Scanf("%d\n", &a)
		A[a] = true
	}

	answer[0] = 1
	if A[1] {
		answer[1] = 0
	} else {
		answer[1] = 1
	}
	for s := 2; s <= N; s++ {
		if A[s] {
			answer[s] = 0
		} else {
			answer[s] = (answer[s-2] + answer[s-1]) % 1000000007
		}
	}
	fmt.Printf("%d\n", answer[N])
}


Measured memory_bytes: 8192
#pragma GCC target("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>

#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>
#define deb(x)		cout << #x << " " << x << endl

using namespace std;
using ll  = long long;
using lld = long double;
#define int ll
const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;
const int N = 105;
const int K = 100005;
int ar[N] , dp[N][K + 10];

signed main(){

#ifndef ONLINE_JUDGE
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);

    int n , k;
    cin >> n >> k;
    fo(i , n) cin >> ar[i];
    
    dp[0][0] = 1;

    fo(i , n){
        fo(j , K){
            //if(dp[i][j] == 0) break;
            
            dp[i + 1][j] = ((dp[i + 1][j] % MOD + dp[i][j] % MOD) + MOD) % MOD;
            if(j + ar[i] + 1 > K)
                continue;
            dp[i + 1][j + ar[i] + 1] = ((dp[i + 1][j + ar[i] + 1] % MOD - dp[i][j] % MOD) + MOD) % MOD; 
        }
        fo(j , K)
            if(j)
                dp[i + 1][j] = ((dp[i + 1][j] % MOD +  dp[i + 1][j - 1] % MOD) + MOD ) % MOD; 
    }

//    fo(i , n + 1){
//        fo(j , k + 10)
//            cout << dp[i][j] << " " ;
//        cout << '\n';
//    }
//
    cout << dp[n][k] << '\n';;

    return 0;

}



Measured memory_bytes: 81708
#include"bits/stdc++.h"
#include"math.h"
using namespace std;
typedef long long ll;

int main(){

vector<int> s(3);
int n=3;
for(int i=0;i<n;i++) cin >> s[i];
sort(s.begin(),s.end());
int ans=0;
if(s[0]==s[1]){ans=s[2]-s[1];}
else if((s[1]-s[0])%2==0){
ans+=(s[1]-s[0])/2;
ans+=(s[2]-s[1]);
}
else{
ans+=s[2]-s[1];
s[0]+=ans;
ans+=(s[2]-s[0])/2;
ans+=2;}
cout << ans << endl;}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a[5];
	int n;
	cin>>n;
	for(int i=1;i<=4;i++){
		a[i]=n%10;
		n=n/10;
	}
	if((a[1]==a[2]&&a[2]==a[3])||(a[2]==a[3]&&a[3]==a[4]))
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
	
}


Measured memory_bytes: 256
// ALDS_1_1_A Insertion Sort

#include <iostream>
#define NMAX	100

void outArray(int *array, int n){
	for(int i=0 ; i<n-1 ; i++){
		std::cout << array[i] << " ";
	}
	std::cout << array[n-1] << std::endl;

	return;
}

int main(int argc, char *argv[]){
	int N;
	int A[NMAX];

	std::cin >> N;
	for(int i=0 ; i<N ; i++){
		std::cin >> A[i];
	}

	for(int i=1 ; i<N ; i++){
		outArray(A, N);
		int target = A[i];
		int j = i;
		while( (j > 0) && (target < A[j-1]) ){
			A[j] = A[j-1];
			j--;
		}
		A[j] = target;
	}
	outArray(A, N);

	return 0;
}




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

using namespace std;

int main(){
  while(true){
    int a,b;
    char op;
    cin >> a >> op >> b;
    if(op == '+') cout << a + b << endl;
    else if(op == '-') cout << a - b << endl;
    else if(op == '*') cout << a * b << endl;        
    else if(op == '/') cout << a / b << endl;
    else break;
  }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n, ans = INT_MAX, s1, s2;
const int N = 100;
int arr[N + 4];

bool can(int mid)
{
    s1 = s2 = 0;
    for(int i = 0; i <= mid; i++)
        s1 += arr[i];
    for(int i = mid + 1; i < n; i++)
        s2 += arr[i];
    return (abs(s1 - s2) < ans);
}

int main()
{
    IO;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    for(int i = 1; i < n; i++)
    {
        for(int j = 0; j < i; j++)
            s1 += arr[j];
        for(int j = i; j < n; j++)
            s2 += arr[j];
        ans = min(ans, abs(s1 - s2));
        s1 = s2 = 0;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MOD3 1000000000
#define MOD2 998244353 
float PHI = 1.6180339;
const float  PI_F=3.14159265358979f;
#define MAX 1000 m
#define endl "\n"    
#define manhunt 32 
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define pi 3.1415926535897932384626433
//typedef long long float;
#define int long long
//#define double long double
typedef pair<int, int> pii;
//#define float unsigned long long
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define CHAR_SIZE 26 

int modpow(int x, int n, int m) { if (n == 0) return 1%m; long long u = modpow(x,n/2,m); u = (u*u)%m; if (n%2 == 1) u = (u*x)%m; return u; } 


int add(int x, int y,int m) 
{
	x += y;
	if (x >= m) return x - m;
	return x;
}
int sub(int x, int y) 
{
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int inv(int a, int m = MOD2)
{
	return modpow(a, m - 2, m);
}
int mul(int a, int b,int m) 
{
	return (long long) a * b % m;
}


int nCrModp(int n, int r, int p) 
{ 
    int C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
    for (int i = 1; i <= n; i++) 
    { 
        for (int j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
}

int32_t main()
{
    /* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout); */
    FAST
    cout << fixed << setprecision(12);

    int n,k;
    cin>>n>>k;
    int arr[n+10];
    int ans=0;
    for(int i=0;i<n;i++)
    cin>>arr[i];
    sort(arr,arr+n);
    for(int i=0;i<k;i++)
    ans+=arr[i];
    cout<<ans<<endl;
    
    
    return 0;
}





Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <climits>
#include <unordered_set>
using namespace std;
 
#define debug(x) cout << #x << "==" << x << endl;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define MAX_V 1000
#define INF INT_MAX / 2
 
int V, E;
bool ex_edge[MAX_V][MAX_V];
 
int d[MAX_V][MAX_V];
int used[MAX_V][MAX_V];          // 最短ろで使用した辺
 
void warshall_floyd(  ) {
 
  for(int a = 0; a < V; a++) {
    for(int b = 0; b < V; b++) {
      for(int c = 0; c < V; c++) {
        if( a == b || a == c || b == c) {
          continue;
        } else if( d[b][a] + d[a][c] < d[b][c] ) {
          used[b][c]--;
          d[b][c] = d[b][a] + d[a][c];
        }
      }
    }
  }
}
 
 
int main() {
  ios::sync_with_stdio(false);
 
 
  cin >> V >> E;
 
  fill( d[0], d[V], INF );
  for(int v=0; v < V; v++) {
    d[v][v] = 0;
  }
 
  for(int i = 0; i < E; i++) {
    int v, w, cost;
    cin >> v >> w >> cost;
    v--;w--;
    d[v][w] = cost;
    d[w][v] = cost;
    used[v][w] = 1;
    used[w][v] = 1;
    ex_edge[v][w] = true;
    ex_edge[w][v] = true;
  }
 
  warshall_floyd();
 
  int ans = 0;
  for(int v = 0; v < V; v++) {
    for(int w = v; w < V; w++) {
      if( ex_edge[v][w] && used[v][w] <= 0 ) {
          ans++;
      }
    }
  }
  cout << ans << "\n";
 
  return 0;
}

Measured memory_bytes: 1152
#abc123d

x,y,z,k=map(int,raw_input().split())
a=sorted(map(int,raw_input().split()),reverse=True)
b=sorted(map(int,raw_input().split()),reverse=True)
c=sorted(map(int,raw_input().split()),reverse=True)

ab=sorted([i+j for i in a for j in b],reverse=True)
res=sorted([ij+l for ij in ab[:k] for l in c],reverse=True)
for i in res[:k]:
 print i


Measured memory_bytes: 165320
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		/*
		 * ?????????????????? [C/C++] ?????????????????? string ???????????°????¨????????????°???
		 * ???????????????????????°??????????????????????????? < ??? > ??¨
		 * ??????????????? == ????????¨???????????¨?????§????????????
		 *
		 * taro hanako
		 *
		 * card N; turn N; Win 3; Draw 1;
		 *
		 */

		Scanner sc = new Scanner(System.in);

		// declear variable
		int cardN; // same turn;
		int win = 3, draw = 1; // point
		String taro[], hanako[]; // player hands
		int pointT = 0, pointH = 0;// player`s point

		/*
		 * Sample Input 3
		 * cat dog
		 * fish fish
		 * lion tiger
		 * Sample Output 1 7
		 */

		// input Card N;
		cardN = sc.nextInt(); // ex : 3
		taro = new String[cardN];
		hanako = new String[cardN];

		// animal name
		for (int i = 0; i < cardN; i++) { // 3
			taro[i] = sc.next();
			hanako[i] = sc.next();

			int game = taro[i].compareToIgnoreCase(hanako[i]);
			if (game == 0) {
				pointT += draw;
				pointH += draw;
			} else if (game > 0) {
				pointT += win;
			} else {
				pointH += win;
			}
		}
		// output
		System.out.println(pointT + " " + pointH);
	}
}

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

int main(){
  long long int n,i,j,l,k,kari=0,kotae=1;
  int a[3];
  a[0]=-1;
  a[1]=-1;
  a[2]=-1;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>k;
    for(j=0;j<=2;j++){
      if(a[j]==k-1){
        a[j]=k;
        kari++;
        for(l=j+1;l<=2;l++){
          if(a[l]==k-1){
            kari++;
          }
        }
        break;
      }
    }
    kotae=(kotae*kari)%1000000007;
    kari=0;
  }
  cout<<kotae;
}


Measured memory_bytes: 256
import math
s=list(input())
half_s=int((len(s)-1)/2)
def kaibun_hantei(p):
  half_l=math.ceil((len(p)-1)/2)
  if len(p)%2==1:
    if p[:half_l]==p[(half_l+1):][::-1]:
      return 100
  else:
    if p[:half_l]==p[(half_l):][::-1]:
      return 100

if kaibun_hantei(s)==100:
  if kaibun_hantei(s[:half_s])==100:
    print('Yes')
  else:
    print('No')
else:
  print('No')
  

Measured memory_bytes: 38384
N, K = map(int, input().split())
A = list(map(int, input().split()))

dic = {}
for i, v in enumerate(A):
    dic[i+1] = v

town = 1
s = set()
l = []
for _ in range(K):
    l.append(town)
    s.add(town)
    town = dic[town]
    if town in s:
        stop_twon = town
        break
if N <= K:
    list_first_split = l[:l.index(stop_twon)]
    list_second_split = l[l.index(stop_twon):]
    print(list_second_split[(K - (len(list_first_split))) % len(list_second_split)])
else:
    print(town)

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

int main(){
    int n,m;
    while(cin>>n,n){
        vector<vector<int> >vec;
        for(int i=0;i<n;i++){
            vector<int>v;
            for(int j=0;j<n;j++){
                cin>>m;
                v.push_back(m);
            }
            vec.push_back(v);
        }
        for(int i=0;i<n;i++){
            int s=0;
            for(int j=0;j<n;j++)
                s+=vec[i][j];
            vec[i].push_back(s);
        }
        vector<int>v;
        for(int i=0;i<n+1;i++){
            int s=0;
            for(int j=0;j<n;j++)
                s+=vec[j][i];
            v.push_back(s);
        }
        vec.push_back(v);
        for(int i=0;i<n+1;i++){
            for(int j=0;j<n+1;j++)
                cout<< setfill (' ') << setw (5)<<vec[i][j];
            cout<<endl;
        }
    }
}

Measured memory_bytes: 1232