akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a+b<c*2) cout<<a*d+b*e<<endl;
    else if((d>e&&a>c*2)||(e>d&&b>c*2)) cout<<max(d,e)*2*c<<endl;
    else if(d>e) cout<<e*2*c+(d-e)*a<<endl;
    else cout<<d*2*c+(e-d)*b<<endl;
}
    

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    ans = 0
    while True:
        for i in range(n):
            if a[i] % 2 == 0:
                a[i] //= 2
            else:
                print(ans)
                return
        ans += 1 

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
def solve3():
    """solve1の変形
    ２種類のパターンしかないので分岐して調べる
    """
    S = list(input())
    c1, c2 = 0, 0
    for i in range(len(S)):
        # 正解を1010...とした場合
        if i % 2 == 0 and S[i] == '0':
            c1 += 1
        if i % 2 == 1 and S[i] == '1':
            c1 += 1
        # 正解を0101...とした場合
        if i % 2 == 0 and S[i] == '1':
            c2 += 1
        if i % 2 == 1 and S[i] == '0':
            c2 += 1
    return(min(c1, c2))

def solve2():
    l = list(str(input()))
    l = [int(i) for i in l]
    cnt = 0
    # チェックをしたのち次のものを適切な色に変更する
    # 全てのタイルに適用することで間違いをカウントすることができる
    for i in range(len(l)-1):
        if(l[i]==l[i+1]):
            cnt+=1
        if(l[i]==0):
            l[i+1]=1
        elif(l[i]==1):
            l[i+1]=0
    return cnt

def solve1():
    s = input()
    n = len(s)

    counter_bw = 0
    counter_wb = 0

    # 指定された長さに従って正解の文字列を作ってしまう
    if n % 2 == 0:
        bw = "01" * (n // 2)
        wb = "10" * (n // 2)
    else:
        bw = "01" * (n // 2) + "0"
        wb = "10" * (n // 2) + "1"

    # 作成した正解文字列と違うところを比較
    for i in range(n):
        if s[i] != bw[i]:
            counter_bw += 1
        if s[i] != wb[i]:
            counter_wb += 1

    # 2種類しかないので違いが少ないほうの違いの数を示せばいい
    return min(counter_bw, counter_wb)

# print(solve1())
print(solve2())


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

dic = {}
for i in range(N):
    dic[i] = A[i] - 1
   
res = 0
for i in range(N):
    if dic[A[i] - 1] == i:
        res += 1
        
        
print(res//2)

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

#define REP(_i, _cnt) for(int _i=0;_i<_cnt;i++)
#define ALL(ctn) ctn.begin(),ctn.end()
#define FI first
#define SE second

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<pair<int, int>> red(N);
  vector<pair<int, int>> blue(N);

  REP(i,N) cin >> red[i].SE >> red[i].FI;
  REP(i,N) cin >> blue[i].FI >> blue[i].SE;
  sort(ALL(red), greater<pair<int, int>>());
  sort(ALL(blue));

  /*cout << "red:" << endl;
  REP(i, N) cout << red[i].FI << ' ' << red[i].SE << endl;
  cout << "blue:" << endl;
  REP(i, N) cout << blue[i].FI << ' ' << blue[i].SE << endl;*/

  vector<bool> rf(N, false);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (!rf[j] && red[j].FI < blue[i].SE && red[j].SE < blue[i].FI) {
        ans++;
        rf[j] = true;
        break;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int n = in.nextInt();

        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= 9; j++) {
                if (i * j == n) {
                    System.out.println("Yes");
                    return;
                }
            }
        }

        System.out.println("No");
    }
}


Measured memory_bytes: 23636
using AtCoderBeginnerContest133.Questions;
using AtCoderBeginnerContest133.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest133.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var nab = inputStream.ReadIntArray();
            var n = nab[0];
            var a = nab[1];
            var b = nab[2];

            yield return Math.Min(n * a, b);
        }
    }
}


namespace AtCoderBeginnerContest133
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest133.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest133.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define rep2(i,a,b) for (ll i = (a); i < (b); ++i)

#define INF 1E18



int main(){
    int n;
    cin>>n;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    
    int ans = 0;
    rep2(i,1,n-1){
        if((p[i-1]<p[i] && p[i]<p[i+1]) || (p[i+1]<p[i] && p[i]<p[i-1])) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long int ll;
typedef pair<int, int> P;
#define INF 1e9 + 7

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

    int n;
    cin >> n;
    string s[n];
    int p[n];
    int id[n];
    rep(i,n){
        id[i] = i+1;
        cin >> s[i] >> p[i];
    }
    
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(s[i] > s[j]){
                swap(s[i], s[j]);
                swap(id[i], id[j]);
                swap(p[i], p[j]);
            }
            if(s[i]==s[j] && p[i]<p[j]){
                swap(s[i], s[j]);
                swap(id[i], id[j]);
                swap(p[i], p[j]);
            }
        }
    }
    
    for(auto data : id){
        cout << data << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <numeric>
using namespace std;
#define MAX_N 400

template<class T> inline bool chmax(T& a, T b) { if(a < b) {a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if(a > b) {a = b; return true; } return false; }
const long long INF = 1LL << 60;

// Input
int N, X, Y;

int main() {
  cin >> N >> X >> Y;
  vector<int> ans(N,0);
  X--;
  Y--;

  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int d = min(min(abs(j-i),abs(X-i) + 1 + abs(j-Y)),abs(Y-i) + 1 + abs(j-X));
      ans.at(d)++;
    }
  }
  for (int d = 1; d < N; d++) {
    cout << ans.at(d) << endl;
  }
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll h[100000];
ll a, b; ll dif; int n;
bool don(ll k) {
	ll cnt = 0;
	rep(i, n) {
		ll x = h[i] - b*k;
		if (x < 0)continue;
		cnt += (x + dif - (ll)1) / dif;
	}
	if (cnt <= k)return true;
	else return false;
}
int main() {
	cin >> n;
	cin >> a >> b;
	rep(i, n) {
		cin >> h[i];
	}
	ll sum = 0; dif = a - b;
	sort(h, h + n, greater<ll>());
	ll le = 0; ll ri = MOD;
	while (ri - le > 1) {
		ll mid = (le + ri) / (ll)2;
		if (don(mid))ri = mid;
		else le = mid;
	}
	cout << ri << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
 
// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
 
using namespace std;
using namespace __gnu_pbds;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
const int INF = 1e16;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 1e9 + 7;

const int maxn = 70000;
int dp[maxn], v[20][20], ans[maxn];

int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> v[i][j];
    for(int mask = 0; mask < (1 << n); mask++)
    {
        int a = mask, cnt = 0, flag = 0, pos;
        while(a)
        {
            if(a & 1)
            {
                if(!flag)
                    pos = cnt, ans[mask] = ans[mask ^ (1 << pos)];
                else
                    ans[mask] += v[pos][cnt];
                flag = 1;
            }
            a >>= 1;
            cnt++;
        }
    }
    for(int mask = 0; mask < (1 << n); mask++)
    {
        for(int submask = mask; submask > 0; submask = mask & (submask - 1))
        {
            dp[mask] = max(dp[mask], dp[mask ^ submask] + ans[submask]);
        }
    }
    int t = (1 << n) - 1;
    cout << dp[t] << endl;
    return 0;
}


Measured memory_bytes: 1280
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    s = S()
    if s[2] == s[3] and s[4] == s[5]:
        print('Yes')
    else:
        print('No')

main()



Measured memory_bytes: 7876
//ITP1_2_B:   Range
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		String[] abc = in.readLine().split(" ");

		int a = Integer.parseInt(abc[0]);
		int b = Integer.parseInt(abc[1]);
		int c = Integer.parseInt(abc[2]);

		if (a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 16892
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main()
{
	ll a,b,c,k;cin>>a>>b>>c>>k;
	if(k<=a)cout<<k;
	if(k<=a+b && k>a)cout<<a;
	if(k<=a+b+c && k>a+b)cout<<(a)-(k-a-b);
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

   bool ok=true;
   if(n%2==1) ok=false;
   else{
      rep(i, n/2) if(s[i]!=s[n/2+i]) ok=false;
   }

   if(ok) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}


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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<vector<int>> trie(1, vector<int>(26, -1));
    vector<vector<int>> cnt(1, vector<int>(26));
    vector<bool> term(1);

    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        int x = 0;
        vector<int> z(26);
        for (char c : s) {
            z[c - 'a']++;
        }
        for (int j = (int)s.size() - 1; j >= 0; j--) {
            for (int t = 0; t < 26; t++) {
                if (z[t] > 0) {
                    cnt[x][t]++;
                }
            }
            int c = s[j] - 'a';
            z[c]--;
            if (trie[x][c] == -1) {
                trie[x][c] = trie.size();
                trie.push_back(vector<int>(26, -1));
                cnt.push_back(vector<int>(26));
                term.push_back(false);
            }
            x = trie[x][c];
        }
        term[x] = true;
    }
    long res = 0;
    for (int x = 0; x < trie.size(); x++) {
        for (int t = 0; t < 26; t++) {
            if (trie[x][t] != -1 && term[trie[x][t]]) {
                res += cnt[x][t] - 1;
            }
        }
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 268636
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep1(i,n) for (int i=1;i<(n+1);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;



int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    ll money = 1000;
    ll mx = 0;
    ll stock = 0;
    rep(i,n){
        cin >> a[i];
    }
    
    for(int i=0;i<n-1;i++){
        if(a[i] > a[i+1]){
            money += a[i] * stock;
            stock=0;
            
        }else if(a[i] < a[i+1]){
            stock += money / a[i];
            money %= a[i];
        }
        mx = max(mx,money); 
        // cout << money << endl;
    }
    money += a[n-1] * stock;
    stock=0;
    mx = max(mx,money); 
    cout << mx << endl;
   	
  	
    
    
    return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
char s1[5], s2[5], s3[5];

int main() {
	while(~scanf("%s %s %s", s1, s2, s3)) {
		printf("%c%c%c\n", s1[0], s2[1], s3[2]);
	}
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val a = Array(n) { sc.nextInt() }
    var money = 1000L
    var kabu = 0L
    for (i in 0 until n) {
        if (i + 1 < n && a[i] < a[i + 1]) {
            val buy = money / a[i]
            kabu += buy
            money -= buy * a[i]
        }
        if (i == n - 1 || a[i] > a[i + 1]) {
            money += kabu * a[i]
            kabu = 0
        }
    }
    println(money)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34376
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
typedef vector<int> vi;

int main() {
  int N, x;
  cin >> N >> x;
  int a[N];
  rep(i, N) cin >> a[i];
  sort(a, a+N);

  int ans = 0;

  for (int i = 0; i < N; i++) {
    if (x >= a[i]) {
      ++ans;
      x -= a[i];
    }
  }

  if (ans == N && x > 0) --ans;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <limits>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '

const int MAXN = 200;
//ll a[MAXN], ST[MAXN * 4], LZ[MAXN*4];

/*bool perfectSquare(ll x){
    ll s = sqrt(x);
    if(s *s == x) return true;
    else return false;
}*/
typedef long double ld;

int main() { 
    ios_base::sync_with_stdio(0); cin.tie(0); 
    int n = 0, m = 0;
    cin >> n >> m;
    int sum = 0, number = 0;
    for(int i = 0; i < m; ++i){
        cin >> number;
        sum+=number;
    }
    if(sum > n){cout << -1 << endl;}
    else{cout << n - sum << endl;}
  
    return 0; 
} 


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

using namespace std;

int main() {

	int A, B, C, D;

	cin >> A >> B >> C >> D;

	if(A * B == C * D) cout << A * B << endl;
	if(A * B > C * D) cout << A * B << endl;
	if(A * B < C * D) cout << C * D << endl;

	return 0;
}

Measured memory_bytes: 256
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 2000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int n, mn[N][N], a[N], x;

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> x;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) mn[i][i] = a[i];
	for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) mn[i][j] = min(mn[i][j - 1], a[j]);
	ll ans = INF;
	for (int i = 0; i <= n; i++){
		ll res = 0;
		for (int j = 0; j < n; j++){
			ll delta = a[j];
			if (i != 0){
				if (j >= i){
					delta = min(delta, mn[j - i][j - 1]);
				}else{
					if (j != 0) delta = min(delta, min(mn[0][j - 1], mn[n - (i - j)][n - 1]));
					else delta = min(delta, mn[n - (i - j)][n - 1]);
				}
			}
			//cout << i << ' ' << delta << '\n';
			res += delta;
		}
		ans = min(ans, res + x * i);
	}
	cout << ans;










	return 0;
}


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

typedef long long ll;

const ll INTEG = pow(10,9) + 7;

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int &i:p){
    cin >> i;
  }

  int counter = 0;
  for(int i = 1; i < n - 1; i++){
    vector<int> s = {p[i-1],p[i],p[i+1]};
    sort(s.begin(),s.end());
    if(s[1] == p[i])
      counter++;
  }

  cout << counter << endl;
}

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

#define ll long long

ll gcd(ll a, ll b) {
  return b ? gcd(b, a % b) : a;
}
void exgcd(ll a, ll b, ll& x, ll& y) {
  if (!b) {
    x = 1, y = 0;
  } else {
    exgcd(b, a % b, y, x);
    y -= (a / b) * x;
  }
}
ll inv(ll a, ll Mod) {
  ll x, y;
  exgcd(a, Mod, x, y);
  return x < 0 ? x + Mod : x;
} 

typedef class vec {
  public:
    ll dx, dy;
    int c;

    vec(ll dx, ll dy, int c) : dx(dx), dy(dy), c(c) { }
} vec;

int T;
ll A, X, B, Y, C;
vector<vec> conv;

void solve() {
  scanf("%lld%lld%lld%lld%lld", &A, &X, &B, &Y, &C);
  ll g = gcd(A, B), ga, gb;
  A /= g, B /= g, C /= gcd(g, C);
  ga = gcd(A, C);
  A /= ga, Y /= ga, C /= ga;
  gb = gcd(B, C);
  B /= gb, X /= gb, C /= gb;
  if (C == 1) {
    printf("%lld\n", X + Y);
    return;
  }

  conv.clear();
  ll W = C, H = A * inv(B, C) % C, x0 = 0, ia = inv(A, C), p = 0, np;
  while (W && H) {
    if (W >= H) {
      ll t = W / H;
      W -= t * H;
      x0 += t * H;
      np = x0 * B % C * ia % C;
      np += !np * C;
      conv.emplace_back((np - p) / t, H, t);
      p = np;
    } else {
      if (!(H % W)) { 
        conv.emplace_back(C - p, W, 1);
        break;
      } else {
        H %= W;
      }
    }
  }

  ll l = Y / C + 1, r = X + Y, mid;
  while (l <= r) {
    mid = (l + r) >> 1;
    ll ca = 0, cb = mid * C;
    for (auto v : conv) {
      ll ub = min((cb - Y - 1) / v.dy + 1, 1ll * v.c * mid);
      ub = min(ub, 1000000001ll);
      ca += v.dx * ub;
      cb -= v.dy * ub;
      if (ca > X || cb <= Y) {
        break;
      }
    }
    if (ca <= X && cb <= Y) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  printf("%d\n", l - 1);
}

int main() {
  scanf("%d", &T);
  while (T--) {
    solve();
  }
  return 0;
}


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

const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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 COM(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(){
    ll N,K; cin >> N >> K;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    

    COMinit();
    ll res = 0;
    
    rep(i,N){

        res -= A[i] * COM(N-1-i, K-1);
        res %= MOD;
        if(res < 0) res += MOD;

        res += A[i] * COM(i, K-1);
        res %= MOD;

    }
    cout << res << endl;
}

Measured memory_bytes: 15804
#include <bits/stdc++.h>
using namespace std;
int A, B, C, K;

int main() {
	cin >> A >> B >> C >> K;

	int ans = 0;
	if (K > A) {
		ans += A;
		if (K - A > B) {
			ans;
			if (K - A - B > 0) {
				ans -= (K - A - B);
			}
		}
	}
	else {
		ans += K;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 3756
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

void findDivisor(int n, vector<int>& divisor)
{
    divisor.clear();
    stack<int> stk;
    for(int i=1; i*i<=n; ++i){
        if(n % i == 0){
            divisor.push_back(i);
            if(i * i < n)
                stk.push(n / i);
        }
    }
    while(!stk.empty()){
        divisor.push_back(stk.top());
        stk.pop();
    }
}

const int MOD = 1000000007;

long long power(int a, int b)
{
    long long ret = 1;
    long long tmp = a;
    while(b > 0){
        if(b & 1){
            ret *= tmp;
            ret %= MOD;
        }
        tmp *= tmp;
        tmp %= MOD;
        b >>= 1;
    }
    return ret;
}

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

    if(n % 2 == 0){
        n /= 2;
        vector<int> div;
        findDivisor(n, div);

        int m = div.size();
        vector<long long> v(m, 0);
        for(int i=0; i<m; ++i){
            int x = div[i];
            v[i] = x * power(k, x) % MOD;
            for(int j=0; j<i; ++j){
                int y = div[j];
                if(x % y == 0){
                    v[i] -= v[j] * (x / y) % MOD;
                    v[i] += MOD;
                    v[i] %= MOD;
                }
            }
        }

        long long ans = 0;
        for(int i=0; i<m; ++i){
            ans += v[i];
            ans %= MOD;
        }
        cout << ans << endl;
    }
    else{
        vector<int> div;
        findDivisor(n, div);

        int m = div.size();
        vector<long long> v(m, 0);
        for(int i=0; i<m; ++i){
            int x = div[i];
            v[i] = x * power(k, (x+1)/2) % MOD;
            for(int j=0; j<i; ++j){
                int y = div[j];
                if(x % y == 0){
                    v[i] -= v[j] * (x / y) % MOD;
                    v[i] += MOD;
                    v[i] %= MOD;
                }
            }
        }

        long long ans = 0;
        for(int i=0; i<m; ++i){
            ans += v[i];
            ans %= MOD;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a[10],b[10];
    for(int i=0;i<10;i++)cin>>a[i];
    for(int i=0;i<10;i++)cin>>b[i];
    sort(a,a+10);
    sort(b,b+10);
    int pa,pb;
    pa=pb=0;
    for(int i=7;i<10;i++){
        pa+=a[i];
        pb+=b[i];
    }
    cout<<pa<<" "<<pb<<endl;
    return 0;

}

Measured memory_bytes: 1180
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;

vector<int> dijkstra(int i,int n, vector<vector<pair<int, int>>> graph) {
  vector<int> d(n, INF);
  d[i] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
  q.push(make_pair(0, i));
  while (!q.empty()) {
    pair<int, int> p = q.top();
    q.pop();
    int v = p.second;
    if (d[v] < p.first) {
      continue;
    }
    for (auto x : graph[v]) {
      if (d[x.first] > d[v] + x.second) {
        d[x.first] = d[v] + x.second;
        q.push(pair<int, int>(d[x.first], x.first));
      }
    }
  }
  return d;
}


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

  vector<vector<pair<int, int>>> graph(N);
  int a, b, c;
  REP(i, N-1){
    cin >> a >> b >> c;
    a--; b--;
    graph[a].push_back(make_pair(b, c));
    graph[b].push_back(make_pair(a, c));
  }

  int Q, K;
  cin >> Q >> K;
  vector<int> dist = dijkstra(K-1, N, graph);
  
  int x, y;
  REP(i, Q){
    cin >> x >> y;
    cout << dist[x-1]+dist[y-1] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 18160
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int[] a = new int[n-1];
			for(int i=0;i<n-1;i++) a[i] = sc.nextInt();
			
			long sum = 0;
			int now = 0;
			int p;
			for(int i=0;i<m;i++){
				p = sc.nextInt();
				if(p>0){
					for(int j=0;j<p;j++) sum += a[now+j];
				}else{
					for(int j=0;j>p;j--) sum += a[now+j-1];
				}
				now += p;
			}
			System.out.println(sum%100000);
		}	
	}	
}

Measured memory_bytes: 95716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

// (?????????,??????,??????)
struct edge{ int to,cap,rev; };

const int MAX_V = 404; // TODO:initialize
const int F_INF = 1010101010; // TODO:initialize
vector<edge> G[MAX_V];
int level[MAX_V]; // s??????????????¢
int iter[MAX_V]; // ???????????§??????????????£??????

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

void dinic_bfs(int s){
    memset(level,-1,sizeof(level));
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        rep(i,G[v].size()){
            edge &e = G[v][i];
            if(e.cap>0 && level[e.to]<0){
                level[e.to] = level[v]+1;
                que.push(e.to);
            }
        }
    }
}

// ?¢?????????????dfs??§??¢???
int dinic_dfs(int v, int t, int f){
    if(v==t) return f;
    for(int &i=iter[v]; i<G[v].size(); ++i){
        edge &e=G[v][i];
        if(e.cap>0 && level[v]<level[e.to]){
            int d = dinic_dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

// s??????t???????????§???
int max_flow(int s, int t){
    int flow = 0;
    while(1){
        dinic_bfs(s);
        if(level[t]<0) return flow;
        memset(iter,0,sizeof(iter));
        int f;
        while((f=dinic_dfs(s,t,F_INF))>0) flow+=f;
    }
}

const int M=12345678;

int solve()
{
    rep(i,MAX_V) G[i].clear();

    int w,h;
    scanf(" %d %d", &w, &h);

    int sr = 0;
    int r[20][20];
    rep(i,h)rep(j,w)
    {
        scanf(" %d", &r[i][j]);
        sr += r[i][j];
    }

    int S = w*h, T = S+1;

    int dx[4]={1,-1,0,0}, dy[4]={0,0,1,-1};
    #define IN(x,y) (0<=x && x<w && 0<=y && y<h)
    rep(i,h)rep(j,w)
    {
        int u = w*i+j;
        if((i+j)%2) add_edge(u, T, r[i][j]);
        else add_edge(S, u, r[i][j]);
        rep(k,4)
        {
            int nx = j+dx[k], ny = i+dy[k];
            if(IN(nx,ny))
            {
                int v = w*ny+nx;
                if((i+j)%2) add_edge(v, u, M);
                else add_edge(u, v, M);
            }
        }
    }

    return sr-max_flow(S,T);
}

int main()
{
    int CASE;
    scanf(" %d", &CASE);
    rep(c,CASE) printf("Case %d: %d\n", c+1, solve());
    return 0;
}

Measured memory_bytes: 3280
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;


public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskT solver = new TaskT();
        solver.solve(1, in, out);
        out.close();
    }
    
    

    static class TaskT {
    	static int counter = 0;
        public void solve(int testNumber, InputReader in, PrintWriter out) {

        	String input = in.next();
        	if(!input.endsWith("s"))
        		out.print(input+"s");
        	else if(input.endsWith("s"))
        		out.print(input+"es");
        }
        
     
        
        

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

        public int nextInt() {
            return Integer.parseInt(next());
        }
        
        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}



Measured memory_bytes: 36808
#include<bits/stdc++.h>
using namespace std;
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(n) for(int i=0;i<n;i++)
#define ll long long
ll mob=1000000007;
using namespace std;
int main()
{ int n,k;
cout<<fixed;
cout<<setprecision(12);
cin>>n>>k;
int a[n];
FOR(n) cin>>a[i];
double sum[n+1];
sum[0]=0;
sum[1]=(double)(a[0]+1)/(2);
for(int i=2;i<=n;i++)
{
    sum[i]=sum[i-1]+(double)((a[i-1]+1))/(2);
}
double sum1=0;
for(int j=0;j<n-k+1;j++)
{
    double d=sum[j+k]-sum[j];
   
    if(sum1<d)
    sum1=d;
}
cout<<sum1;
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h> 

int main(void)
{
	int A[100][100] = {0}, b[100] = {0}, c[100] = {0};
	int m, n, i, j;

	scanf("%d %d", &n, &m);

	for(i = 0; i < n; i++)
	{
		for(j = 0; j < m; j++)
		{
			scanf("%d",&A[i][j]);
		}
	}

	for(i = 0; i < m; i++)
	{
		scanf("%d", &b[i]);
	}

	for(i = 0; i < n; i++)
	{
		for(j = 0; j < m; j++)
		{
			c[i] = c[i] + A[i][j] * b[j];
		}
	}

	for(i = 0; i < n; i++)
	{
		printf("%d\n",c[i]);
	}

	return 0;
}

Measured memory_bytes: 648
#include<bits/stdc++.h>
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

struct Dinic{
	struct Edge{int to,cap,rev;};
	vector<vector<Edge>>G;
	vector<int>level,iter;
	void addEdge(int from,int to,int cap){
		G[from].push_back({to,cap,len(G[to])});
		G[to].push_back({from,0,len(G[from])-1});
	}
	void bfs(int s){
		fill(all(level),-1);
		level[s]=0;
		queue<P>que;que.push({0,s});
		while(len(que)){
			P p=que.front();que.pop();
			if(level[p.second]<p.first)continue;
			for(Edge e:G[p.second]){
				if(e.cap>0&&level[e.to]==-1){
					level[e.to]=p.first+1;
					que.push({level[e.to],e.to});
				}
			}
		}
	}
	int dfs(int v,int t,int f){
		if(v==t)return f;
		for(int &i=iter[v];i<len(G[v]);i++){
			Edge &e=G[v][i];
			if(e.cap>0&&level[e.to]>level[v]){
				int d=dfs(e.to,t,min(f,e.cap));
				if(d>0){
					e.cap-=d;
					G[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	int maxFlow(int s,int t){
		int flow=0;
		while(1){
			bfs(s);
			if(level[t]<0)return flow;
			fill(all(iter),0);
			int f=0;
			while((f=dfs(s,t,inf))>0){
				flow+=f;
			}
		}
	}
	Dinic(int N):G(N),level(N),iter(N){}
};

int H,W;
char c[105][105];
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
char ans[105][105];
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>H>>W;
	Dinic F(H*W+2);
	rep(i,H)rep(j,W){
		cin>>c[i][j];ans[i][j]=c[i][j];
		if((i+j)%2)F.addEdge(H*W,i*W+j,1);
		else F.addEdge(i*W+j,H*W+1,1);
	}
	rep(i,H)rep(j,W)if((i+j)%2&&c[i][j]=='.')rep(k,4){
		int nx=i+dx[k],ny=j+dy[k];
		if(nx<0||ny<0||nx>=H||ny>=W||c[nx][ny]=='#')continue;
		F.addEdge(i*W+j,nx*W+ny,1);
	}
	cout<<F.maxFlow(H*W,H*W+1)<<"\n";
	rep(i,H){
		rep(j,W){
			if(c[i][j]=='#'||(i+j)%2==0)continue;
			for(auto e:F.G[i*W+j])if(e.cap==0&&e.to/W<H){
				if(e.to/W==i-1){ans[i][j]='^';ans[i-1][j]='v';}
				else if(e.to/W==i+1){ans[i][j]='v';ans[i+1][j]='^';}
				else if(e.to%W==j-1){ans[i][j]='<';ans[i][j-1]='>';}
				else {ans[i][j]='>';ans[i][j+1]='<';}
				break;
			}
		}
	}
	rep(i,H){rep(j,W)cout<<ans[i][j];cout<<"\n";}
}

Measured memory_bytes: 5976
/// awoooooo

# include <bits/stdc++.h>
# define sz(x) (int)((x).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;

const int N = (int)2e5 + 5;
const int inf = (int)1e9 + 7;

int n;
int d[N];

int main(){
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i){
    int x;
    scanf("%d", &x);
    d[x] = d[x - 1] + 1;
  }
  printf("%d", n - *max_element(d + 1, d + 1 + n));
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#define MAX_N 100
#define MAX_M 100

int main() {
  int A[MAX_N][MAX_M], b[MAX_M], product[MAX_M];
  int n_size, m_size;

  scanf("%d %d%*c", &n_size, &m_size);

  for(int i = 0; i < n_size; i++) {
    for(int j = 0; j < m_size; j++) {
      scanf("%d", &A[i][j]);
    }
  }

  for(int i = 0; i < m_size; i++) {
    scanf("%d%*c",&b[i]);
  }

  for(int i = 0; i < n_size; i++) {
    int product_elem = 0;

    for(int j = 0; j < m_size; j++) {
      product_elem += A[i][j] * b[j];
    }

    product[i] = product_elem;
  }

  for(int i = 0; i < n_size; i++) {
    printf("%d\n", product[i]);
  }
}



Measured memory_bytes: 2804
#define ll				long long
#define MOD				1000000007

#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

typedef struct den {
	int sw[10];
	int scnt;
	int p;
} den;

int sw[10];
int scnt;
den dens[10];
int dcnt;
int acnt;

FILE *in, *ans;
int tno;

int out(const char *s) {
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int outi(int i) {
	char s[128];
	sprintf(s, "%d\n", i);
	out(s);
	return 0;
}

int outd(double d) {
	char s[128];
	sprintf(s, "%.10lf\n", d);
	out(s);
	return 0;
}

int outll(ll l) {
	char s[128];
	sprintf(s, "%lld\n", l);
	out(s);
	return 0;
}

int geti() {
	int i;
	fscanf(in, "%d", &i);
	return i;
}

ll getll() {
	ll l;
	fscanf(in, "%lld", &l);
	return l;
}

int getstr(char *s) {
	fscanf(in, "%s", s);
	return 0;
}

int fnc2(int sno) {
	int i, j;

	if (sno >= scnt) {
		for (i = 0; i < dcnt; i++) {
			int ocnt = 0;
			for (j = 0; j < dens[i].scnt; j++) {
				ocnt += sw[dens[i].sw[j] - 1];
			}
			if (ocnt % 2 != dens[i].p) {
				return 0;
			}
		}

		acnt++;

		return 0;
	}

	sw[sno] = 1;
	fnc2(sno + 1);

	sw[sno] = 0;
	fnc2(sno + 1);

	return 0;
}

int fnc() {
	int i, j;

	scnt = geti();
	dcnt = geti();

	for (i = 0; i < dcnt; i++) {
		dens[i].scnt = geti();
		for (j = 0; j < dens[i].scnt; j++) {
			dens[i].sw[j] = geti();
		}
	}
	for (i = 0; i < dcnt; i++) {
		dens[i].p = geti();
	}

	fnc2(0);

	outi(acnt);

	return 0;
}

int main() {

#ifdef TEST
	for (tno = TEST_SNO; tno <= TEST_ENO; tno++) {
		char str[128];
		sprintf(str, "test%d.txt", tno);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", tno);
		ans = fopen(str, "r");
		fnc();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc();
#endif

	return 0;
}


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

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

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

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

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;


int main(){
  string s;
  cin >> s;
  rep(i, 19){
    if (i == 5 || i == 13) cout << " ";
    else cout << s[i];
  }
  cout << endl;

}


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	
	int n;
	cin >> n;
	int a;
	int ans=0;
	rep(i,n){
		cin >> a;
		if(i%2==0 && a%2==1){
			ans++;
		}
	}

	cout << ans << endl;

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3636
#ifdef EPIQ_LOCAL
#define DEBUG
#endif

#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#ifdef DEBUG
#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T> void debug2(T b, T e) { auto it=b; while (it != e) cerr << *it++ << " "; cerr << endl; }
#define TRACE(x) x
#else
#define debug(x)
template<typename T> void debug2(T b, T e) {}
#define TRACE(x)
#endif
#define mp(x, y) make_pair((x),(y))
#define pb(x) push_back(x)
#define eb emplace_back
#define forn(v, b, e) for (auto v = (b); v < (e); v++)
#define SZ(x) ((int)(x).size())
#define st first
#define nd second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
const ld pi = acos(-1);
template<typename T1, typename T2>
ostream& operator<< (ostream& os, const pair<T1,T2>& p) {os << "[" << p.first << "," << p.second << "]"; return os;}
template<typename T1, typename T2, typename T3>
ostream& operator<< (ostream& os, const tuple<T1,T2,T3>& t) {os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")"; return os;}

void solve() {
    ll X;
    
    cin >> X;
    ll t = 100;
    for (int y = 1; ; y++) {
        t += t / 100;
        if (t >= X) {
            cout << y << endl;
            return;
        }
    }
}

int main()
{
    TRACE(clock_t _t1 = clock();)
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(12);

    solve();

    TRACE(cerr << "Time elapsed: " << (double)(clock() - _t1) / CLOCKS_PER_SEC << endl;)

    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define N 140000
#define mod 1000000007
#define pp pair<ll,ll>
typedef long long int ll;
typedef long double ld;
#define MP make_pair

#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++)     
void fastIO(void);

void decimal(int);
ll modmulti(ll, ll, ll);
ll modadd(ll, ll, ll);
ll modpower(ll, ll, ll);
ll gcd(ll, ll );
ll modinv(ll, ll);




int main()
{
 ll a,b;
 cin>>a>>b;
 ll ans = max(a+b,a-b);
 ans = max(ans,a*b);
 cout<<ans<<endl;
}























void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}

void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b, ll m){
   return ((a%m)*(b%m))%m;
}
ll modadd(ll a, ll b, ll m){
   return ((a%m)+(b%m))%m;
}
ll modpower(ll a, ll n, ll m){
   if(n==0)
      return 1;
   ll result = 1;
   while(n>0){
      if(n%2==1)
         result = modmulti(result,a,m);
      a = modmulti(a,a,m);
      n = n/2;
   }
   return result;
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a, ll m){
   return modpower(a,m-2,m);
}


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

int main()
{
    string s;
    cin>>s;
    int n=s.size()-1,ans=0;
    for(int i=0;i<=n/2;i++)
        if(s[i]!=s[n-i]) ans++;
    cout<<ans<<endl;
    return 0;
}

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

int n, t;
struct P {
    int c, t;
}R[101];
int cmp(P a, P b) {
    return a.t < b.t;
}
int ans = 987654321;
int main() {
    ios::sync_with_stdio(false);
    cin >> n >> t;
    for (int i = 0; i < n; i++) {
        cin >> R[i].c >> R[i].t;
    }
    sort(R, R+n, cmp);

    for (int i = 0; i < n; i++) {
        if (R[i].t <= t) {
            ans = min(ans, R[i].c);
        }
    }
    if (ans != 987654321)
        cout << ans << endl;
    else
        cout << "TLE\n";
    return 0;
}



Measured memory_bytes: 256
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

const string YES = "Yes";
const string NO = "No";

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(std::string s){

    if(s.size() % 2){
        cout << "No" << endl;
        return;
    }
    bool fl = true;
    for(int i = 0; i < s.size(); i += 2)
        fl &= (s.substr(i, 2) == "hi");
    cout << (fl ? "Yes" : "No") << endl;
}


signed main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
C = [list(map(int, input().split())) for j in range(10)]
for i in range(10):
    for j in range(10):
        for k in range(10):
            C[j][k] = min(C[j][k], C[j][i] + C[i][k])
 
S = 0
for i in range(H):
    for x in list(map(int, input().split())):
        if x != -1:
            S += C[x][1]
print(S)

Measured memory_bytes: 3064