akhauriyash/Code-Regression huggingface dataset:
data = list(map(int, input().split()))
mat1 = [[0 for j in range(data[1])] for i in range(data[0])]
mat2 = [[0 for j in range(data[2])] for i in range(data[1])]
mat3 = [[0 for j in range(data[2])] for i in range(data[0])]
for i in range(data[0]):
    row = list(map(int, input().split()))
    for j in range(data[1]):
        mat1[i][j] = row[j]
for i in range(data[1]):
    row = list(map(int, input().split()))
    for j in range(data[2]):
        mat2[i][j] = row[j]
for i in range(data[0]):
    for j in range(data[2]):
        elem = 0
        for k in range(data[1]):
            elem += mat1[i][k] * mat2[k][j]
        mat3[i][j] = elem
for i in range(len(mat3)):
    str_mat3 = list(map(str, mat3[i]))
    print(" ".join(str_mat3))



Measured memory_bytes: 6888
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front priority_queue

#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define debug(...) 42
#endif

#define endl '\n'
#define ll long long
#define rint register int
#define minpq priority_queue <int, vector<int>, greater<int> >
#define maxpq  priority_queue <int>

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define conutBits(n)	__builtin_popcount(n)
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

int32_t main() {
	ios::sync_with_stdio(0); 		cin.tie(0); cout.tie(0);

	ll t, i, x, j, y, d, 	z, k, n;
	cin >> x >> k >> d;

	x = abs(x);
	ll needd = x / d;
	if (needd > k) {z = x - d * k;}

	else {
		k -= needd;
		if (k % 2) {z = abs(x - d * needd - d);}
		else {z = x - d * needd;}
	}
	// ce(z);
	cout << z;
	debug(z, x);
}



Measured memory_bytes: 3644
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define FILE_NAME "a"


int n, a, b, c, d;

bool read() {
	if  (scanf("%d%d%d%d%d", &n, &a, &b, &c, &d) < 5) {
		return 0;
	}
	return 1;
}



bool solve() {
	const int steps = n - 1;
	for (int plus = 0; plus <= steps; ++plus) {
		ll mn = plus * 1ll * c;
		ll mx = plus * 1ll * d;

		const int minus = steps - plus;
		ll mn2 = - minus * 1ll * d;
		ll mx2 = - minus * 1ll * c;

		// eprintf("steps=%d, plus=%d, mn=%lld, mx=%lld, mn2=%lld, mx2=%lld\n", steps, plus, mn, mx, mn2, mx2);

		mn += mn2;
		mx += mx2;

		if  (a + mn <= b && b <= a + mx) {
			return 1;
		}
	}
	return 0;
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	while (read()) {
		puts(solve() ? "YES" : "NO");
	}

#ifdef LOCAL
	cerr.precision(5);
	cerr << "Time: " << fixed << (double) clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Main
{
    public static class Program
    {

        static void Main(string[] arg)
        {
            string input = Console.ReadLine();
            var answer = "";
            switch (input)
            {
                case "A":answer = "T";
                    break;
                case "T":answer = "A";
                    break;
                case "C":answer = "G";
                    break;
                case "G":answer = "C";
                    break;
            }
            Console.WriteLine(answer);
            Console.ReadLine();
        
        }
        
        #region libraries
        private static int[] GetIntList(string line)
        {
            return line.Split(' ').Select(x => int.Parse(x)).ToArray();

        }
        private static double[] GetDoubleList(string line)
        {
            return line.Split(' ').Select(x => double.Parse(x)).ToArray();

        }
        private static ulong[] GetUlongList(string line)
        {
            return line.Split(' ').Select(x => ulong.Parse(x)).ToArray();
        }
        private static long[] GetLongList(string line)
        {
            return line.Split(' ').Select(x => long.Parse(x)).ToArray();
        }
        private static int SearchNearest(this IEnumerable<int> list, int target)
        {
            var min = list.Min(c => Math.Abs(c - target));
            return list.First(c => Math.Abs(c - target) == min);
        }
        public static int Gcd(int a,int b)
        {
            if(a < b)
            {
                Gcd(b, a);
            }
            while (b != 0)
            {
                var rm = a % b;
                a = b;
                b = rm;
            }
            return a;
        }
        #endregion
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define print(X) cout << (X) << "\n"
#define _ << " " <<
static const int INF = 1e+9+7;

int main(){
  int N,K;
  cin >> N >> K;
  if(N%K!=0) print(1);
  else print(0);

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
int main() {
    int n = 0;
    cin >> n;
    vector<int> s(n - 1, 0);
    vector<int> e(n - 1, 0);
    for(int i = 0; i < n - 1; ++i) {
        cin >> s[i] >> e[i];
    }
  
    unordered_map<int, unordered_map<int, int>> graph;
    for(int i = 0; i < n - 1; ++i) {
        graph[s[i]][e[i]] = graph[e[i]][s[i]] = 0;
    }
    
    queue<int> ique;
    ique.push(1);
    while(!ique.empty()) {
        int front = ique.front();
        ique.pop();
        
        if(front == n) { continue; }
        
        vector<int> wait;
        unordered_set<int> used;
        for(auto i = graph[front].begin(); i != graph[front].end(); ++i) {
            if(i->second == 0) { wait.push_back(i->first); }
            if(i->second > 0) { used.insert(i->second); }
            if(front < i->first) { ique.push(i->first); }
        }
        int nextAvail = 1;
        for(int i = 0; i < wait.size(); ++i) {
            while(used.find(nextAvail) != used.end()) {
                nextAvail++;
            }
            used.insert(nextAvail);
            graph[front][wait[i]] = nextAvail;
            graph[wait[i]][front] = nextAvail;
        }
    }
    
    int kind = 0;
    vector<int> answer;
    for(int i = 0; i < n - 1; ++i) {
        kind = max(kind, graph[s[i]][e[i]]);
        answer.push_back(graph[s[i]][e[i]]);
    }
    cout << kind << endl;
    for(int i = 0; i < n - 1; ++i) {
        cout << answer[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 21412
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
ct = {i : 0 for i in range(n+1)}
ct[0] = 3
MOD = 10**9+7
res = 1
for a in a_ls:
    res = res * ct[a] % MOD
    ct[a] -= 1
    ct[a+1] += 1
print(res)

Measured memory_bytes: 62108
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
using namespace std;
typedef long long ll;
int a[1010];
int main()
{
    int n;scanf("%d",&n);
    int maxx=-1,minn=10000;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        minn=min(minn,a[i]);
        maxx=max(maxx,a[i]);
    }
    printf("%d\n",maxx-minn);
    return 0;
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    if ((max(a, b) - min(a, b)) % 2 == 1)
    {
        cout << "IMPOSSIBLE" << endl;
    }
    else
    {
        cout << (max(a, b) - min(a, b)) / 2 + min(a, b) << endl;
    }
}


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

const ll mod = 1e9 + 7;

int main() {
  int n, t;
  cin >> n >> t;
  int maxpf = INT_MIN;
  int minx = INT_MAX;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x - minx > maxpf) {
      maxpf = x - minx;
      ans = 1;
    } else if (x - minx == maxpf) {
      ans += 1;
    }
    minx = min(minx, x);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

int main(){
  char s;
  cin >> s;

  if(isupper(s) )
    cout << "A" << endl;
  else
    cout << "a" << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,n) for ( int i = (a); i < (n); ++i)
#define REP(i,n) for( int i = 0; i < (n); ++i )
#define ALL(obj) (obj).begin(), (obj).end()

int head = 0;
int tail = 0;

vector<double> ring;

inline double dice_exp( const int n )
{
    return ( double(n) + 1.0 ) / 2.0;
}

inline double push( double c ) 
{
    ring[tail] = c;
    tail = (tail + 1) % ring.size();
    return c;
}

inline double pop()
{
    double v = ring[head];
    head = (head+1) % ring.size();
    return v;
}

inline double get(const int n)
{
    return ring[ ( head + n ) % ring.size() ];
}

int main()
{
    int N,K;

    cin >> N >> K;
    ring.resize(N);

    REP(i,K) {
        push(0.0);
    }

    double max = 0.0;
    double sum = 0.0;
    REP(i,N) {
        int v;
        cin >> v;
        double e = dice_exp( v );
        
        sum -= pop();
        sum += e;
        push(e);

        // cout << head << " " << tail << " " << sum << endl;
        // cout << e << endl;
        if( max < sum  ) {
            max = sum;
        }
    }

    cout << fixed << max << endl;
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    vector<int> a(3); cin >> a[0] >> a[1] >> a[2];
    sort(ALL(a));
    cout << (a[0]+a[1]==a[2]?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    int M;
    cin>>N>>M;
    int sum=0;
    vector<int>a(M,0);
    for(int i=0;i<M;i++){
        cin>>a[i];
        sum=sum+a[i];
    }
    if(N-sum<0){
        cout<<-1<<endl;
        return 0;
    }
    cout<<N-sum<<endl;
    //cout<<N<<" "<<sum<<endl;
}


Measured memory_bytes: 3664
#include <iostream>

int gcd(int x, int y)
{
    int s, l, r;
    s = x < y ? x : y;
    l = x > y ? x : y;
    r = l % s;
    while (r != 0) {
        l = s;
        s = r;
        r = l % s;
    }
    return s;
}

int abs(int x)
{
    return x < 0 ? -x : x;
}

int main()
{
    int n, x, y, ans;
    std::cin >> n >> x;
    std::cin >> ans;
    ans -= x;
    ans = abs(ans);
    for (int i = 1; i < n; i++) {
        std::cin >> y;
        ans = gcd(ans, abs(y-x));
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
# from collections import defaultdict
# from heapq import heappush, heappop, heapify
# from bisect import bisect_left, insort_left
# from itertools import groupby


class Solution:
    def main(self):
        N = int(input())
        # d = list(map(int, input().split()))
        s = input()
        res = 1
        for i in range(N-1):
            if s[i] != s[i+1]:
               res += 1
        print(res)


if __name__ == '__main__':
    Solution().main()


Measured memory_bytes: 3316
#include <iostream>
#include <math.h>
#include <set>
#include<vector>
#include<string>
#include <algorithm>
#include<queue>
#include<map>
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define per(i,j,k) for(int i = (int)j;i >= (int)k;i --)
#define F(i,k) for(int i=(int)0;i<(int)k;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
typedef long long ll;
const int maxn = 5e3 + 5;
using namespace std;
ll m,n;
ll dis[maxn];
bool inQ[maxn];
int cnt[maxn];
vector<pii> E[maxn];
int SPFA() {
	rep(i, 1, n)dis[i] = 1e18, inQ[i] = 0,cnt[i]=0;
	queue<int> Q;
	Q.push({ 1 });
	dis[1] = 0;
	cnt[1]++;
	while (!Q.empty()) {
		auto now = Q.front();
		Q.pop();
		if (cnt[now] >= 3 * n + 1)dis[now] = -1e9;
		inQ[now] = 0;
		for (auto v : E[now]) {
			if (dis[v.first] > dis[now] + v.second) {
				dis[v.first] = dis[now] + v.second;
				if (!inQ[v.first] && cnt[v.first] <= 3 * n + 1)Q.push(v.first), inQ[v.first] = 1, cnt[v.first]++;
			}
		}
	}
}
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int p;
	cin >> n >> m >> p;

	rep(i, 1, m) {
		int x, y, z;
		cin >> x >> y >> z;
		E[x].push_back({y,  p - z });
	}
	SPFA();
	
	if (-dis[n]>=1e9)cout << -1<<endl;
	 else cout << max(0ll,-dis[n]) << endl;
		cin >> m;
}

/*
2 2 10
1 2 100
2 2 100
*/

Measured memory_bytes: 512
# -*- coding: utf-8 -*-


a = [e for e in input().split()]
# a = ['1', '2', '+', '3', '4','-', '*']
# a = ['1', '2', '+']
l = []


for x in a:

    if x not in ['+', '-', '*']:
        x = int(x)
        l.append(x)
    else:
        a = l.pop()
        b = l.pop()

        if x == '+':
            l.append(b + a)
        elif x == '-':
            l.append(b - a)
        elif x == '*':
            l.append(b * a)


print(sum(l))

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

bool good(vector<pair<int, int>>& A, vector<pair<int, int>>& B) {
    int N = A.size();
    for (int i=0;i<N;i++) {
        if (A[i].first > B[i].first) return false;
    }
    return true;
}

bool scary(vector<pair<int, int>>& A, vector<pair<int, int>>& B) {
    int N = A.size();
    for (int i=1;i<N;i++) {
        if (A[i].first <= B[i-1].first) return false;
    }
    return true;
}

bool is_cycle(vector<int>& perm) {
    int N = perm.size();
    int start = 0;
    for (int i=0;i<N-1;i++) {
        start = perm[start];
        if (start == 0) {
            return false;
        }
    }
    return true;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N;
    cin >> N;
    
    vi A(N);
    vi B(N);

    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<N;i++) cin >> B[i];

    vector<pair<int, int>> Asort;
    vector<pair<int, int>> Bsort;

    for(int i=0;i<N;i++) {
        Asort.push_back(make_pair(A[i], i));
        Bsort.push_back(make_pair(B[i], i));
    }

    sort(Asort.begin(), Asort.end());
    sort(Bsort.begin(), Bsort.end());

    if (!good(Asort, Bsort)) {
       // cout << "not good" << endl;
        cout << "No" << endl;
    } else if (!scary(Asort, Bsort)) {
       // cout << "not scary" << endl;
        cout << "Yes" << endl;
    } else {
        vi perm(N);
        for (int i=0;i<N;i++) {
            perm[Asort[i].second] = Bsort[i].second;
        }
        if (is_cycle(perm)) {
         //   cout << "scary and cycle" << endl;
            cout << "No" << endl;
        } else {
           // cout << "scary and no cycle" << endl;
            cout << "Yes" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3052
fun main(args: Array<String>) {
    println(rectangle(readLine()!!))
}

fun rectangle(input: String) : String {
    val height = input.split(" ")[0].toInt()
    val width = input.split(" ")[1].toInt()

    val area = height * width
    val circumference = height * 2 + width * 2

    return "$area $circumference"
}


Measured memory_bytes: 32060
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; 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(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char notes[110][10];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll ans = 0;
	rep(i, n) {
		for (ll j = i + 1;j < n;++j) {
			for (ll k = j + 1;k < n;++k) {
				if (a[i] == a[j] || a[j] == a[k])continue;
				if (a[k] < a[i] + a[j])ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
while True:
    x = input().split()
    x_int = [int(i) for i in x]

    if x_int[0] == 0 and x_int[1] == 0:
        break
    for i in range(x_int[0]):
        for j in range(x_int[1]):
            if i == 0 or i == x_int[0]-1:
                print('#',end='')
            else:
                if j == 0 or j == x_int[1]-1:
                    print('#',end = '')
                else:
                    print('.',end = '')
        print()
    print()

Measured memory_bytes: 9028
import sys

readline = sys.stdin.readline
N = int(input())
shop = [int(readline().replace(' ', ''), 2) for _ in range(N)]
profits = [list(map(int, readline().split())) for _ in range(N)]
ans = -10**20
for bit in range(1, 1<<10+1):
    profit = 0
    cnt = 0
    for s, p in zip(shop, profits):
        num = bin(bit&s).count('1')
        if num:
            cnt += 1
        profit += p[num]
    if cnt and ans < profit:
        ans = profit
print(ans)


Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	long A,B,C=0;
	char op;
	while(scanf("%ld %c %ld",&A,&op,&B)!=EOF)
	{
		if(op=='+')
		{
			C=A+B;
		    printf("%ld\n",C);			
		}
		else
		{
			C=A-B;
			printf("%ld\n",C);
	    }
	}
	return 0;
}

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

using namespace std;

#define int long long 
#define INF 21000000000



signed main(){
		string s;
		cin >> s;
		string ans;
		if (s == "Sunny") ans = "Cloudy";
		else if(s == "Cloudy") ans = "Rainy";
		else ans = "Sunny";

		cout << ans << endl;
}



Measured memory_bytes: 256
class Dice < Array
	def roll(drct)
		self.replace(drct.split("").inject(self){|arr,s|
		case s
		when "E" then
			arr = [arr.at(3),arr.at(1),arr.at(0),arr.at(5),arr.at(4),arr.at(2)]
		when "N" then
			arr = [arr.at(1),arr.at(5),arr.at(2),arr.at(3),arr.at(0),arr.at(4)]
		when "S" then
			arr = [arr.at(4),arr.at(0),arr.at(2),arr.at(3),arr.at(5),arr.at(1)]
		when "W" then
			arr = [arr.at(2),arr.at(1),arr.at(5),arr.at(0),arr.at(4),arr.at(3)]
		end
		})
	end
	def top
		at(0)
	end
end

a = Dice.new(gets.split.map(&:to_i))
a = a.roll(gets.chomp)
puts a.top

Measured memory_bytes: 8716
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s;
	while(getline(cin,s),!cin.eof()){
		while(1){
			size_t p=s.find("@");
			if(p==string::npos)break;
			s.replace(p,3,string(int(s[p+1]-'0'),s[p+ 2]));
		}
		cout<<s<<"\n";
	}
}

Measured memory_bytes: 1192
n = int(input())
b = list(map(int, input().split()))
fl = [False] * n
q = []
while len(b) != 0:
    ptr = -1
    for i in range(len(b)):
        if b[i] == i+1:
            ptr = i

    if ptr == -1:
        break

    _b = []
    for i in range(len(b)):
        if i == ptr:
            q.append(b[i])
        else:
            _b.append(b[i])

    b = _b.copy()

if ptr == -1:
    print(ptr)
else:
    for qq in reversed(q):
        print(qq)


Measured memory_bytes: 65068
#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;
const ll LINF = 1e18;

/*
<url:https://arc073.contest.atcoder.jp/tasks/arc073_b>
問題文============================================================
 あなたは N 個の物と、強度 W のバッグを持っています。 i 個目の物は、重さが wi で価値が vi です。
 
 あなたは、物のうちいくつかを選び、バッグに入れます。 ただし、選んだ物の重さの和は W 以下でなくてはいけません。
 
 あなたは、バッグに入れた物の価値の総和を最大化したいです。
 
 制約
 1≦N≦100
 1≦W≦10^9
 1≦wi≦10^9
 すべての i=2,3,…,N について、w1≦wi≦w1+3
 1≦vi≦10^7
 W,wi,vi はすべて整数である

=================================================================

解説=============================================================

 制約で wもvも大きいので他の部分に注目する
  => すべての i=2,3,…,N について、w1≦wi≦w1+3
 
 これによって、w1を基準とすればwiが大きくなる範囲をかなり限定できる
 よって、入れる物全ての総和は　100*(w1+3) = 100*w1 + 300
 ここで、この問題は w1を高々100個　＋　余剰分で重さがさらに高々 300 増えるナップサック問題と捉えることができる
 
 したがって、このようなdpを考えることができる
 
 dp[i][j][k] := i番目の物を見た時、重さが j*w1 + k となっている時の価値の最大
 
 計算量は 100 * 100 * 300 = 3*10^6 で十分間に合う
 
================================================================
*/

ll dp[110][110][330];

void init(){
    for(int i = 0; i < 110; i++) for(int j = 0; j < 110; j++) for(int k = 0; k < 330; k++)
        dp[i][j][k] = -1;
}

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    init();
    ll N,W; cin >> N >> W;
    vector<ll> w(N),v(N);
    for(int i = 0; i < N;i++) cin >> w[i] >> v[i];
    ll base_w = w[0];
    for(int i = 0; i < N;i++) w[i] -= base_w;
    
    dp[0][0][0] = 0;
    for(int i = 0; i < N;i++){
        for(int j = 0; j < 110; j++){
            for(int k = 0; k < 330; k++){
                if(dp[i][j][k] == -1) continue;
                dp[i+1][j][k] = max(dp[i+1][j][k],dp[i][j][k]);
                dp[i+1][j+1][k+w[i]] = max(dp[i+1][j+1][k+w[i]],dp[i][j][k] + v[i]);
            }
        }
    }
    ll ans = 0;
    for(int j = 0; j < 110; j++){
        for(int k = 0; k < 330; k++){
            if(dp[N][j][k] == -1) continue;
            if(base_w*j + k <= W){
                ans = max(ans,dp[N][j][k]);
            }
        }
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 31488
import java.util.Scanner;
public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            int a = sc.nextInt();
            int b = sc.nextInt();
            int area = a * b;
            int length = 2 * (a + b);
            System.out.println(area + " " + length);
            sc.close();
        }
}


Measured memory_bytes: 26320
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0

for i in range(A + 1):
    for j in range(B + 1):
        for s in range(C + 1):
            total_value = 500*i + 100*j + 50*s     
            if total_value == X:     
                count += 1                        
print(count)

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var n, m, t, p, x, sum int
	fmt.Scan(&n)
	ts := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&t)
		ts[i] = t
	}
	fmt.Scan(&m)
	ps := make([][]int, m)
	for i := 0; i < m; i++ {
		ps[i] = make([]int, 2)
		fmt.Scan(&p, &x)
		ps[i][0] = p - 1
		ps[i][1] = x
	}
	for _, v := range ts {
		sum += v
	}
	for i := 0; i < len(ps); i++ {
		fmt.Println(sum - ts[ps[i][0]] + ps[i][1])
	}
}


Measured memory_bytes: 512
a,b,c,x,y = map(int, input().split())
only = a * x + b * y 
ans = only
for i in range(1,x + 1):
    current = 0
    current = c * i * 2
    if y - i >= 0:
        current = current + a * ( x - i ) + b * (y - i)
    else:
        current = current + a * ( x - i )
    if ans > current:
        ans = current
for i in range(1,y + 1):
    current = 0
    current = c * i * 2
    if x - i >= 0:
        current = current + a * ( x - i ) + b * ( y - i )
    else:
        current = current + b * ( y - i )
    if ans > current:
        ans = current
print(ans)

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

int main()
{
   string s;
   cin >> s;
   for(int i = 0; i < s.size(); ++i)
   {
       if(s[i] == '9')
       {
           cout << "Yes\n";
           return 0;
       }
   }
   
   cout << "No\n";
   return 0;
}


Measured memory_bytes: 256
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op=="+":
        print(a + b)
    elif op =="-":
        print(a - b)
    elif op =="*":
        print(a * b)
    elif op =="/":
        print(a // b)
    else:break
  


Measured memory_bytes: 5596
s = input()

if s == 'SAT':
    print(1)
if s == 'FRI':
    print(2)
if s == 'THU':
    print(3)
if s == 'WED':
    print(4)
if s == 'TUE':
    print(5)
if s == 'MON':
    print(6)
if s == 'SUN':
    print(7)

Measured memory_bytes: 9048
#include <stdio.h>
#define MAX 100000

int partition(int *,int,int);

int main()
{
  int i,a[MAX],n,x,k;

  scanf("%d",&n);
  for(i=1 ; i<=n ; i++)
  {
    scanf("%d",&a[i]);
  }

  k = partition(a,1,n);

  for(i=1 ; i<=n ; i++)
  {
    if(i!=k && i!=n)printf("%d ",a[i]);
    else if (i==k)printf("[%d] ",a[i]);
    else if(i== n) printf("%d",a[i]);
  }
  printf("\n");

  return 0;
}

int partition(int *A,int p,int r)
{
  int j,n,m,x,i;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++)
  {
    if(A[j]<=x)
    {
      i=i+1;
      n=A[i];
      A[i]=A[j];
      A[j]=n;
    }
  }
  m=A[i+1];
  A[i+1]=A[r];
  A[r]=m;
  return i+1;
}



Measured memory_bytes: 2128
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cassert>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int dist[100010];
int num[100010];

int main() {
	ll K;
	cin >> K;
	rep(i,100010) {
		dist[i] = 100;
	}
	rep(i,100010) {
		int t = i;
		while(t) {
			num[i] += t % 10;
			t /= 10;
		}
	}

	priority_queue<pii> q;
	int dst = 100001;
	dist[dst] = num[K];
	//cout << dist[dst] << endl;
	for(int i = 1; i < 10; i++) {
		q.push(pii(-K*i%10, K*i/10));
	}

	while(q.size()) {
		//cout << q.size() << endl;
		pii a = q.top(); q.pop();
		a.fi = -a.fi;
		if(a.fi > dist[a.se])
			continue;
		dist[a.se] = a.fi;
		dist[dst] = min(dist[dst], a.fi + num[a.se]);
		//cout << dist[dst] << endl;
		for(int i = 0; i < 10; i++) {
			if(dist[(a.se+i*K)/10] > a.fi + (a.se+i*K)%10) {
				dist[(a.se+i*K)/10] = a.fi + (a.se+i*K)%10;
				q.push(pii(-dist[(a.se+i*K)/10], (a.se+i*K)/10));
			}
		}
	}

	cout << dist[dst] << endl;
	return 0;
}


Measured memory_bytes: 10348
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

n,a,b=map(int,input().split())
v=list(map(int,input().split()))

dp=[[[-1,0] for j in range(n+1)] for i in range(n+1)]

dp[0][0]=[0,1]
# print(dp)
for i in range(n):
    for j in range(n):
        if dp[i][j][0]==-1:
            continue
        if dp[i][j][0]==dp[i+1][j][0]:
            dp[i+1][j][1]+=dp[i][j][1]

        if dp[i][j][0]>dp[i+1][j][0]:
            dp[i+1][j]=dp[i][j][:]
        
        if dp[i][j][0]+v[i]==dp[i+1][j+1][0]:
            dp[i+1][j+1][1]+=dp[i][j][1]
        
        if dp[i][j][0]+v[i]>dp[i+1][j+1][0]:
            dp[i+1][j+1][0]=dp[i][j][0]+v[i]
            dp[i+1][j+1][1]=dp[i][j][1]
# print(dp)
ans=0
for i in range(a,b+1):
    ans=max(ans, dp[-1][i][0]/i)
print(ans)
cnt=0
for i in range(a,b+1):
    if ans==dp[-1][i][0]/i:
        cnt+=dp[-1][i][1]
print(cnt)

Measured memory_bytes: 67304
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>

#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,n) for(int i=0;i<(n); ++i)
#define rep2(i,n) for(int i=1;i<=(n);++i)

using namespace std;
typedef long long ll;
typedef vector<int> vi;
const int NMAX = 100000;
const int MMAX = 100000;
const int k = 200000;
static const int INF = 1<<21;
static const int NIL = -1;
static const int mod = 1e9+7;

double dp[3000][3000]={0};
ll gcd(ll a, ll b){
if(a<b) swap(a,b);
    if(b==0) return a;
    return gcd(b, a%b);
}

vector<vi> pre(NMAX+1);
vi dist(NMAX+1);
vector<bool> visited(NMAX+1);


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


    char s[101];
    cin >> s;
    int n;
    n = strlen(s);
    int ans = 0;
    rep(i,n){
        if(s[i] != s[n-1-i]){
            ans ++;
        }
    }
    cout << ans/2 << endl;
return 0;
}

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

int main() {
  int n, m, k;
  while (cin >> n >> k >> m && n) {
    vector<int> V;
    for (int i=1; i<=n; i++) {
      V.push_back(i);
    }
    int now = m-1;
    // cerr << "erase: " << V[now] << endl;
    V.erase(V.begin() + now);
    while (V.size() > 1) {
      now = (now + k-1)%(V.size());
      // cerr << "erase: " << V[now] << endl;
      V.erase(V.begin() + now);      
    }
    cout << V[0] << endl;
  }
}

Measured memory_bytes: 1320
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>
#include<limits.h>

int move(int *, int *, int *, int wall[12][8]);

int main()
{
	int i, j, x, y, d;
	char buf[9][8]={0};
	int wall[12][8]={0};

	for(i=0; i<9; i++)
		scanf("%s", buf[i]);

	for(i=2; i<=10; i++){
		for(j=1; j<=5; j++){
			if(buf[i-2][j-1] != 0)
				wall[i][j] = buf[i-2][j-1] - '0';
		}
	}

	printf("R");
	x = 2, y = 1, d = 2;	//up:0 left:1 right:2 down:3

	while(move(&x, &y, &d, wall));

	printf("\n");

	return 0;
}

int move(int *x, int *y, int *d, int wall[12][8])
{

	if(*x == 1 && *y == 1)
		return 0;

	if(*d == 0){
		if(wall[*y*2][*x-1] == 1){
			printf("L");
			(*x)--, *d = 1;
		}else if(wall[*y*2-1][*x] == 1){
			printf("U");
			(*y)--, *d = 0;
		}else if(wall[*y*2][*x] == 1){
			printf("R");
			(*x)++, *d = 2;
		}else{
			printf("D");
			(*y)++, *d = 3;
		}
	}else if(*d == 1){
		if(wall[*y*2+1][*x] == 1){
			printf("D");
			(*y)++, *d = 3;
		}else if(wall[*y*2][*x-1] == 1){
			printf("L");
			(*x)--, *d = 1;
		}else if(wall[*y*2-1][*x] == 1){
			printf("U");
			(*y)--, *d = 0;
		}else{
			printf("R");
			(*x)++, *d = 2;
		}
	}else if(*d == 2){
		if(wall[*y*2-1][*x] == 1){
			printf("U");
			(*y)--, *d = 0;
		}else if(wall[*y*2][*x] == 1){
			printf("R");
			(*x)++, *d = 2;
		}else if(wall[*y*2+1][*x] == 1){
			printf("D");
			(*y)++, *d = 3;
		}else{
			printf("L");
			(*x)--, *d = 1;
		}
	}else{
		if(wall[*y*2][*x] == 1){
			printf("R");
			(*x)++, *d = 2;
		}else if(wall[*y*2+1][*x] == 1){
			printf("D");
			(*y)++, *d = 3;
		}else if(wall[*y*2][*x-1] == 1){
			printf("L");
			(*x)--, *d = 1;
		}else{
			printf("U");
			(*y)--, *d = 0;
		}
	}

	return 1;
}

Measured memory_bytes: 524
// ConsoleApplication.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdio.h"
#include <cstdlib>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>

using namespace std;

static const int IntMax = 1000000000;

int main()
{
	//const int numberOfValues = getIntFromStringInput(cin);
	int numberOfValues;
	cin >> numberOfValues;
	const vector<int> tValues = [&] {
		vector<int> ret; {
			ret.reserve(static_cast<size_t>(numberOfValues));
			int input;
			for (int i = 0; i != numberOfValues; ++i) {
				cin >> input;
				ret.push_back(input);
			}
			return ret;
		}
	}();

	const int maxProfit = [&] {
		int minimum = tValues.front();
		int profit = -IntMax;
		for (int j = 1; j != numberOfValues; ++j) {
			const int val = tValues.at(j);
                        profit = max(profit, val - minimum);
			minimum = min(minimum, val);
			
		}
		return profit;
	}();

	cout << maxProfit << endl;


	return 0;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;int a[500001],i,j,n;
main(){
for(i=2;i<500001;i++){
if(i%7==1||i%7==6){
for(j=2;j<=sqrt(i);j++){
if(a[j]==1&&i%j==0){
a[i]=0;goto E;
}
}
a[i]=1;
E:;
} 
}
while(true){
cin>>n;
if(n<2){break;}printf("%d:",n);
for(i=2;i<=n;i++){
if(a[i]==1&&n%i==0){printf(" %d", i);}
}
cout<<endl;
}
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n, m;
	while (cin >> n >> m, n || m) {
		vector<vector<pair<int, int>>>d(m, vector<pair<int, int>>(m, pair<int, int>(INF, INF)));
		rep(i, 0, m)d[i][i] = make_pair(0, 0);
		int a, b, c, t;
		rep(i, 0, n) {
			cin >> a >> b >> c >> t; a--; b--;
			d[a][b] = d[b][a] = make_pair(c, t);
		}
		rep(k, 0, m) {
			rep(i, 0, m) {
				rep(j, 0, m) {
					d[i][j].first = min(d[i][j].first, d[i][k].first + d[k][j].first);
					d[i][j].second = min(d[i][j].second, d[i][k].second + d[k][j].second);
				}
			}
		}
		int k; cin >> k;
		int p, q, r;
		rep(i, 0, k) {
			cin >> p >> q >> r; p--; q--;
			if (r)cout << d[p][q].second << endl;
			else cout << d[p][q].first << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}


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

    vector<int>a(N+1);
    rep(i,N)cin >>a[i+1];

    int ans = 0;
    for(int i = 1; i<=N;i++){
        if(i %2 == 1 &&  a[i] %2 == 1)ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<array>
#include<algorithm>
#include <random>
std::random_device seed_gen;
std::mt19937 engine(seed_gen());
std::uniform_int_distribution<> dD {0, 364};

int const INF = 1e9;
int const M = 3800;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int D; std::cin >> D;
  int c[26];
  for(int& ci: c) std::cin >> ci;
  std::vector<std::array<int,26>> s(D);
  for(int d = 0; d < D; ++d) {
    for(int& si: s[d]) std::cin >> si;
  }
  
  // greedy
  std::vector<int> t(D);
  int ans = 0;
  int last[26];
  std::fill_n(last, 26, -1);
  for(int d = 0; d < D; ++d) {
    int ma = -INF;
    t[d] = 0;
    for(int T = 1; T <= 26; ++T) {
      int cur = s[d][T-1];
      int sv = last[T-1];
      last[T-1] = d;
      for(int cx = 0; cx < 26; ++cx) {
        cur -= (d-last[cx])*c[cx];
      }
      last[T-1] = sv;
      if(cur > ma) { ma = cur; t[d] = T; }
    }
    ans += ma;
    last[t[d]-1] = d;
  }
  
  auto score = [&]()->int {
    int ans = 0;
    int last[26];
    std::fill_n(last, 26, -1);
    for(int d = 0; d < D; ++d) {
      ans += s[d][t[d]-1];
      last[t[d]-1] = d;
      for(int cx = 0; cx < 26; ++cx) {
        ans -= (d-last[cx])*c[cx];
      }
    }
    return ans;
  };
  
  // modify
  for(int m = 0; m < M; ++m) {
    int d = dD(engine);
    int sv = t[d], tx = 0;
    for(int T = 1; T <= 26; ++T) if(T != sv) {
      t[d] = T;
      int new_ans = score();
      if(new_ans > ans) { ans = new_ans; tx = T; }
    }
    if(tx == 0) t[d] = sv;
  }
  for(int ti: t) std::cout << ti << "\n";
  
  return 0;
}


Measured memory_bytes: 3668
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
struct H{int x,y;};
LL i,j,k,m,n,s,sz,t,pv[100005],vi[100005],w[100005];
H e[200040];
queue<int>B;
int C(H a,H b){return a.x<b.x||a.x==b.x&&a.y<b.y;}
void bfs(int v)
{
	vi[v]=1;
	B.pop();
	for(int i=pv[v];i<pv[v+1];i++)
	{
		if(!vi[e[i].y])B.push(e[i].y);
	}
	if(B.empty())return;
	bfs(B.front());
}
void dfs(int v)
{
	vi[v]=1;
	for(int i=pv[v];i<pv[v+1];i++)
	{
		if(!vi[e[i].y])dfs(e[i].y);
	}
}
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout<<fixed<<setprecision(12);
	cin>>n>>m;
	for(;i<m;i++)
	{
		cin>>e[i].x>>e[i].y;
		e[i+m].x=e[i].y;
		e[i+m].y=e[i].x;
	}
	sz=2*m;
	sort(e,e+sz,C);
	for(i=0;++i<sz;)
	{
		if(e[i].x>e[i-1].x)
		{
			for(j=e[i-1].x;j++<e[i].x;)
			{
				pv[j]=i;
			}
		}
	}
	for(j=e[sz-1].x;j++<n+1;)pv[j]=sz;
	for(i=0;i++<n;)
	{
		if(!vi[i])
		{
			s++;
			dfs(i);
		}
	}
	cout<<s-1;
}

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

int main(){

  int A, K, X, i;
  
  cin >> K >> X;
  A = 2*K-1;
  for(i = 1; i <= A; i++){
  	    
  	cout << X-K+1 << " ";
    K--;
  
  }

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int r0,w,c,r,i;
  while(cin>>r0>>w>>c>>r,r!=0){
    i=0;
    while(1){
      if(r0/w>=c){
	cout<<i<<endl;
	break;
      }
      r0+=r;
      i++;
      }
  }
}

Measured memory_bytes: 3084
using System;
using System.Text;
using System.Linq;

public class ABC158_D {
	private static void Main(string[] args) {
		var s = ReadStr();
		var q = ReadInt();

		var isReversed = false;
		var sbHead = new StringBuilder("");
		var sbTail = new StringBuilder("");
		
		for (int i = 0; i < q; i++) {
			var query = ReadStrsAsArray();
			var t = query[0];

			if (t == "1") {
				isReversed = !isReversed;

			} else {
				var f = query[1];
				var c = query[2];

				if (IsHead(f, isReversed)) sbHead.Append(c);
				else sbTail.Append(c);
			}
		}

		var head = (isReversed) ? sbTail.ToString() : sbHead.ToString();
		head = new string(head.Reverse().ToArray());
		var tail = (isReversed) ? sbHead.ToString() : sbTail.ToString();
		if (isReversed) s = new string(s.Reverse().ToArray());

		var answer = head + s + tail;
		Console.WriteLine(answer);
	}

	private static string ReadStr() => Console.ReadLine().Trim();
	private static string[] ReadStrsAsArray() => Console.ReadLine().Trim().Split();
	private static int ReadInt() => int.Parse(Console.ReadLine().Trim());
	private static bool IsHead(string f, bool isReversed) => (((f == "2") && (isReversed)) || ((f == "1") && (!isReversed)));
}

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

//#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

//#define int long long
using namespace std;
const int INF = 2e9;
const int MOD = 1e9 + 7;
const int MB = 20;

void solve() {
	int a, p;
	cin >> a >> p;
	p += a * 3;
	cout << p / 2;
}


signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 256
a, b, k = gets.chomp.split(" ").map(&:to_i)

lesser_num = [a, b].min

ar = []
for i in 1..lesser_num do
  if ((a % i) == 0) && ((b % i) == 0) then
    ar << i
  end
end

ar = ar.sort.reverse

puts ar[k-1]


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL gcd(LL a,LL b){
	return b?gcd(b,a%b):a;
}
int main(){
	LL a,b,c;int ans=1;
	scanf("%lld%lld",&a,&b);c=gcd(a,b);
	for(LL i=2;i*i<=c;i++){
		if(c%i==0)ans++;
		while(c%i==0)c/=i;
	}
	printf("%d",ans+(c>1));
	return 0;
}

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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll k;
    cin >> n >> k;
    VI a(n), a_count(n, -1);
    REP(i, n) {
        cin >> a[i];
        a[i]--;
    }
    int count = 0;
    int current_i = 0;
    a_count[0] = 0;
    while (true) {
        current_i = a[current_i];
        count++;
        if (a_count[current_i] > -1) break;
        a_count[current_i] = count;
    }

    if (k <= a_count[current_i]) {
        current_i = 0;
        REP(i, k) current_i = a[current_i];
        cout << current_i + 1 << ln;
        return 0;
    }

    k -= a_count[current_i];
    int circle_n = count - a_count[current_i];
    k %= circle_n;
    REP(i, k) current_i = a[current_i];
    cout << current_i + 1 << ln;
    return 0;
}


Measured memory_bytes: 4788
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n=0,m=0,a,b;
	cin>>n>>m;
	vector<int> hl(n);
	vector<pair<int,int>> r(m);
	map<int,int> h;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		hl[i]=a;
		h[i]=1;
	}
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		r[i]={a,b};
		if(hl[a-1]>hl[b-1])
		{
			h[b-1]=0;
		}
		else if(hl[a-1]<hl[b-1])
		{
			h[a-1]=0;
		}
		else if(hl[a-1]==hl[b-1])
		{
			h[a-1]=0;
			h[b-1]=0;
		}
	}
	int c=0;
	for(int i=0;i<n;i++)
	{
		//cout<<i+1<<"-"<<h[i]<<endl;
		c+=h[i];
	}
	cout<<c;
}


Measured memory_bytes: 9016