akhauriyash/Code-Regression huggingface dataset:
def yuclid(a, b):
    if b == 0:
        return a
    else:
        return yuclid(b, a% b)

N = int(input())
t = [int(input()) for i in range(N)]
for i in range(N-1):
    t[i+1] = t[i]*t[i+1]//yuclid(t[i], t[i+1])

print(t[N - 1])


Measured memory_bytes: 2940
n, m, x = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
cost = 0
flag = 0
min = 10000000000000

for i in range(1<<n):
  r = [0]*m
  flag = 0
  cost = 0
  for j in range(n):
    if(i>>j&1):
      cost += a[j][0]
      for k in range(m):
        r[k] += a[j][k+1]
  for k in range(m):
    if(r[k] < x):
      flag = 1
      break
  if(flag == 0 and min > cost):
    min = cost
if(min == 10000000000000):
  print(-1)
else:
  print(min)

Measured memory_bytes: 9220
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>
#include <iterator>

#define along long(x) x.begin(), x.end()
#define MOD 998244353
const unsigned long long M = 1000000007;
const long double PI = 3.141592653589793236L;

typedef long long ll;
typedef long double ld;
#define MAX 50
using namespace std;
void solve()
{
    ll n;
    cin >> n;
    ll arr[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    sort(arr, arr+ n);
    reverse(arr,arr+n);

    ll count =arr[0];
    ll size=n-2;
    ll i=1;
    while(size>0){
        count+=arr[i];
        size--;
        if(size>0){
            count+=arr[i];
            size--;
        }
        else{
            break;
        }
        i++;
    }
    cout<<count<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1;
    //cin>>t;
    while (t--)
    {
        solve();
    }
}

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

def main():
  n, m = map(int, input().split())
  LR = [list(map(int, input().split())) for _ in range(n)]
  
  BIT = [0]*(m+2)
  def add(i, a):
    while i <= m+1:
      BIT[i] += a
      i += i&(-i)
  def bit_sum(i):
    res = 0
    while i > 0:
      res += BIT[i]
      i -= i&(-i)
    return res
  
  for l, r in LR:
    add(l, 1)
    add(r+1, -1)
  
  S = sorted([(r-l+1, l, r) for l, r in LR])
  cnt = 0
  L = []
  for i in range(m, 0, -1):
    while S and S[-1][0] == i:
      c, l, r = S.pop()
      cnt += 1
      add(l, -1)
      add(r+1, 1)
    res = cnt
    for j in range(0, m+1, i):
      res += bit_sum(j)
    L.append(res)
  print(*L[::-1], sep="\n")

if __name__ == "__main__":
  main()

Measured memory_bytes: 128336
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S,T;
	int N;
	cin >> N;
	cin >> S >> T;
	for(int i=0;i<N;i++)cout << S[i] << T[i];
	cout << endl;
}

Measured memory_bytes: 256
from collections import deque
from functools   import reduce

modulo = 10 ** 9 + 7

N, K = map(int, input().split())
adj = {a: [] for a in range(1, N + 1)}
for i in range(N - 1):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

def P(n, k):
    return 0 if n < k else \
           reduce(lambda a, i: a * i % modulo, range(n, n - k, -1), 1)

visited = set()
q = deque([1])
ncoloring = K  # num of coloring of the root

while len(q) > 0:
    u = q.popleft()
    visited.add(u)

    # coloring of the children
    children = [c for c in adj[u] if c not in visited]
    ncoloring *= P(K - 1 if u == 1 else K - 2, len(children))
    ncoloring %= modulo

    q.extend([c for c in children])

print(ncoloring)


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

using namespace std;

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

	int n;
	cin >> n;
	set<string> s;
	int free = 0;
	for(int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		if(1 <= a && a < 400)s.insert("gray");
		else if(400 <= a && a < 800)s.insert("brown");
		else if(800 <= a && a < 1200)s.insert("green");
		else if(1200 <= a && a < 1600)s.insert("water");
		else if(1600 <= a && a < 2000)s.insert("blue");
		else if(2000 <= a && a < 2400)s.insert("yellow");
		else if(2400 <= a && a < 2800)s.insert("orange");
		else if(2800 <= a && a < 3200)s.insert("red");
		else free++;
	}
	if(s.size() == 0)cout << 1 << " " << free << endl;
	else cout << s.size() << " " << s.size() + free << endl;

	return 0;
}


Measured memory_bytes: 256
/*
Original problem: https://atcoder.jp/contests/dp/tasks/dp_i
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

namespace SOLVE {
    void main() {
        int n;
        cin >> n;
        vector < double > p(n); // prob of heads
        REP(i, 0, n) {
            cin >> p[i];
        }

        vector < vector < double >> dp(n + 1, vector < double > (n + 1)); // dp[i][j] is chance of i heads in j flips
        dp[0][0] = 1; // chance of 0 coins and 0 heads is 1
        
        // works out the probability of all dp[i][j]
        REP(coin, 1, n + 1) {
            REP(heads, 0, coin + 1) {
                if (heads == 0) {
                    dp[coin][heads] = dp[coin - 1][heads] * (1 - p[coin - 1]);
                } else {
                    dp[coin][heads] = dp[coin - 1][heads - 1] * p[coin - 1] + dp[coin - 1][heads] * (1 - p[coin - 1]);
                }
            }
        }

        // add all cases when heads are more than tails
        double ans = 0;
        REP(heads, n / 2 + 1, n + 1) {
            ans += dp[n][heads];
        }
        cout << setprecision(15) << ans << endl;

    }
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 70656
import java.util.Scanner

import scala.collection.mutable

object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextInt()
  val m = sc.nextInt()
  val heights = new mutable.HashMap[Int, Int]()
  (1 to n).foreach { i =>
    val h = sc.nextInt()
    heights.put(i, h)
  }
  val lines = (1 to m).map { _ => Line(sc.nextInt(), sc.nextInt()) }
  val groupedLines = new mutable.HashMap[Int, List[Int]]
  addGroupedLines(lines)
  val result = (1 to n).count { i =>
    val height = heights(i)
    val tos = groupedLines.getOrElse(i, Nil)
    val result = tos.forall { to => heights(to) < height }
    result
  }
  println(result)

  def addGroupedLines(lines: Seq[Line]): Unit = {
    lines.foreach { line =>
      groupedLines.put(line.a, line.b :: groupedLines.getOrElse(line.a, Nil))
      groupedLines.put(line.b, line.a :: groupedLines.getOrElse(line.b, Nil))
    }
  }
}

case class Line(a: Int, b: Int)


Measured memory_bytes: 82424
#!/usr/bin/python
# -*- coding: utf-8 -*-
from collections import Counter


def solve():
    while 1:
        try:
            N = int(input())
            A = list(map(int, input().split(" ")))
            MOD = 10 ** 9 + 7
            counter = Counter(A)
            checker = [0 for _ in range(N)]
            for word, cnt in counter.most_common():
                if word > N - 1 or cnt > 2:
                    raise EndLoop
                else:
                    checker[word] = cnt

            if N % 2 == 0:
                for i in range(N):
                    if not i % 2 and checker[i] != 0:
                        raise EndLoop
                    elif i % 2 and checker[i] != 2:
                        raise EndLoop

                print((2 ** (N // 2)) % MOD)
                break
            else:
                for i in range(N):
                    if i == 0 and checker[i] != 1:
                        raise EndLoop
                    elif not i % 2 and i != 0and checker[i] != 2:
                        raise EndLoop
                    elif i % 2 and checker[i] != 0:
                        raise EndLoop

                print(((2 ** ((N - 1) // 2)) % MOD))
                break
        except:
            print(0)
            break


solve()

Measured memory_bytes: 16480
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int k;
	cin >> k;
	string ans = "..........0";
	rep(_, k) {
		int idx = 9;
		while (ans[idx + 1] == '9' || ans[idx] + 1 == ans[idx + 1]) idx--;
		if (ans[idx + 1] == '.') ans[idx + 1] = '1';
		else ans[idx + 1]++;
		for (int i = idx + 2; i < 11; i++) {
			if (ans[i - 1] == '0') ans[i] = '0';
			else ans[i] = ans[i - 1] - 1;
		}
	}
	string s = "";
	for (char c : ans) if (c != '.') s += c;
	cout << stoll(s) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {

	public static void printarray(int[] a,int n){
    	for(int f=0;f<n;f++){
    		if(f<n-1)System.out.print(a[f]+" ");
    		else System.out.println(a[f]);
    	}
	}

	public static void scanarray(int[] a,int n, Scanner s){
    	for(int i=0;i<n;i++){
    		a[i] = s.nextInt();
    	}
	}

	public static void insertsort(int[] a,int n){
		int v,j;
    	for(int i=1;i<n;i++){
    		v=a[i];
    		j=i-1;
    		while(j>=0 && a[j]>v){
    			a[j+1]=a[j];
    			j--;
    		}
    		a[j+1]=v;

    		printarray(a,n);
    	}
	}
    public static void main(String args[]) {
    	Scanner scan = new Scanner(System.in);
    	int n = scan.nextInt();
    	int a[] = new int[n];

    	scanarray(a,n,scan);
    	printarray(a,n);
    	insertsort(a,n);


    }
}

Measured memory_bytes: 30428
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	string str;
	cin>>str;
	
	int val = 0;
	for(int i = 0;i<str.size();i++)
	{
		val = (val + (str[i] - '0'))%9;
	}
	
	if(!val) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;

signed main() {
    ll n, k;
    cin >> n >> k;
    
    ll r = 1;
    
    n -= k;
    
    while (n > 0) {
        n -= k-1;
        r++;
    }
    
    mes(r);
    
    
    
    

}
    
    
    
    
    


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main(){
    int N; cin >> N;
    // int a, b, c, d;
    // cin >> a >> b >> c >> d;
    int A, B; cin >> A >> B;
    int tmp;
    if((N - A - B) > 0 ) tmp = 0;
    else tmp = A + B - N;
    cout << min(A, B) << " " << tmp << endl;

    

    return 0;
}

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

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

  cout << fixed << setprecision(10);

  double a, b, x, pi;
  cin >> a >> b >> x;

  pi = 3.14159265358979;

  if(x > a*a*b/2){
    double y = (2*x/(a*a)) - b;
    cout << (double)90 - (atan2(a, b-y) * ((double)180 / pi)) << endl;
  }
  else if(x == a*a*b/2){
    cout << (double)90 - (atan2(a,b) * ((double)180 / pi)) << endl;
  }
  else{
    double A = 2*x/(b*a);
    cout << (atan2(b,A) * ((double)180 / pi)) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;

ll findGCD(ll i, ll j){
	if(i > j){
		swap(i, j);
	}
	if(!(j % i)){
		return i;
	}
	return findGCD((j % i), i);
}


int main(){
	int len, X, n, cur;
	scanf("%d %d", &len, &X);
	cur = 0;

	for(int i = 0; i < len; i++){
		scanf("%d", &n);
		if(n == X){
			continue;
		}
		if(!cur){
			cur = abs(n - X);
			continue;
		}
		cur = findGCD(cur, abs(n - X));
	}
	cout<<cur<<endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 5e5 + 10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1e9+7;


char s[10][10];
int r[10];
int c[10];
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<n;i++)
	{
		scanf("%s",s[i]);
	}
	int sum = 0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(s[i][j] == '#')
			{
				r[i]++;
				sum++;
			}
		}
	}
	for(int j=0;j<m;j++)
	{
		for(int i=0;i<n;i++)
		{
			if(s[i][j] == '#')
			{
				c[j]++;
			}
		}
	}
	int N = 1<<n;
	int M = 1<<m;
	int ans = 0;
	for(int x=0;x<N;x++)
	{
		vector<int> h;
		for(int i=0;i<n;i++)
		{
			if(((1<<i)&x) != 0)
			{
				h.push_back(i);
				//cnt += r[i]; 
			}
		}
		for(int y=0;y<M;y++)
		{
			vector<int> v;
			for(int j=0;j<m;j++)
			{
				if(((1<<j)&y) != 0)
				{
					v.push_back(j);
				}
			}
			int cnt = 0;
			for(auto e:h)
			{
				cnt += r[e];
			}
			for(auto f:v)
			{
				cnt += c[f];
			}
			for(auto e:h)
			{
				for(auto f:v)
				{
					if(s[e][f] == '#')
					{
						cnt--;
					}
				}
			}
			if(sum - cnt == k)
			{
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3692
#include <stdio.h>
#include <stdlib.h>

long combination(long int n, long int k) {
	if (n < k)return 0;
	if (k > 0) {
		return combination(n, k - 1) * (n - k + 1) / k;
	}
	else {
		return 1;
	}
}

int func(const void *a, const void *b)
{
	long *A = (long *)a;
	long *B = (long *)b;
	if (*A > *B) return 1;
	if (*A < *B) return -1;
	return 0;
}

int main(void) {
	long int N;
	long S[200001];
	long sorted[200001];
	scanf("%ld", &N);
	S[0] = 0;
	for (long int i = 1; i <= N; i++) {
		long temp;
		scanf("%ld", &temp);
		S[i] = S[i - 1] + temp;
	}
	long max = -10000000;
	for (int i = 1; i <= N; i++) {
		if (max < S[i])max = S[i];
	}
	//counting_sort(S, sorted, max, N + 1);
	qsort(S, N + 1, sizeof(long), func);
	long int before = 1;
	long int res = 0;
	for (long int i = 1; i <= N; i++) {
		if (S[i] == S[i - 1]) {
			before++;
		}
		else {
			res += combination(before, 2);
			before = 1;
		}
	}
	res += combination(before, 2);
	printf("%ld\n", res);
	return 0;
}

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

using namespace std;
using ll = long long;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define allpt(v) (v).begin(), (v).end()


const int mod = 1e9 + 7;
const string wsp = " ";
const string tb = "\t";
const string rt = "\n";

class RangeMinorMaxorSumQuery // 0-index
{
    int const intmax = 2147483647;
    int const intmin = 0;
    vector<int> sgt;
    int n;
    int k;

public:
    RangeMinorMaxorSumQuery(int n1, int f = -1)
    {
        if (f == -1)
            f = intmax;
        else if (f == 0)
            f = intmin;
        int na = 1;
        int ka = 0;
        while (na < n1)
        {
            na *= 2;
            ka++;
        }
        for (int i = 0; i < 2 * na; i++)
            sgt.push_back(f);
        n = na;
        k = ka;
    }

    void update_sum(int i, int x)
    {
        i += n;
        sgt[i] = x;
        while (i > 1)
        {
            i /= 2;
            sgt[i] = sgt[2 * i] + sgt[2 * i + 1];
        }
    }

    int getsum(int a, int b, int k = 1, int l = 0, int r = -1) //閉区間 l <= x < r とする
    {
        if (r == -1)
            r = n;
        if (r <= a || b <= l)
            return intmin;
        if (a == l && b == r)
            return sgt[k];
        else
            return getsum(a, min(b, (l + r) / 2), 2 * k, l, (l + r) / 2) + getsum(max(a, (l + r) / 2), b, 2 * k + 1, (l + r) / 2, r);
    }
    void printsegtree()
    {
        for (int i = 0; i < 2 * n; i++)
        {
            cout << sgt[i] << " ";
        }
        cout << endl;
    }
};

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, m, sl, k, a, b, c, ans2, d, e;
    cin >> n >> m;
    int ans;
    ans2 = -1;
    vector<PII> query(m);
    rep(i, m)
    {
        cin >> c >> d;
        query[i] = make_pair(c, d);
    }

    if (n == 1)
        a = 0, b = 10;
    if (n == 2)
        a = 10, b = 100;
    if (n == 3)
        a = 100, b = 1000;

    rep2(i, a, b)
    {
        ans = 0;
        rep(j, m)
        {
            c = query[j].first, d = query[j].second;
            e = 1;
            rep(k, n - c) e *= 10;
            
            if ((i / e) % 10 == d)
                ans++;
        }

        if (ans == m)
        {
            ans2 = i;
            break;
        }
    }

    if (ans2 == -1)
        cout << -1 << rt;
    else
    {
        cout << ans2 << rt;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define pai 3.1415926535

int main(void) {
	
	char S[4];
	scanf("%s", S);
	if (S[0] =='M' ) {
		printf("%d", 6);
	}
	else if (S[0] =='T'&&S[1]=='U' ) {
		printf("%d", 5);
	}
	else if (S[0] =='W' ) {
		printf("%d", 4);
	}
	else if (S[0] =='T'&&S[1]=='H' ) {
		printf("%d", 3);
	}
	else if (S[0] == 'F') {
		printf("%d", 2);
	}

	else if (S[0] == 'S'&&S[1] == 'A') {
		printf("%d", 1);
	}
	else {
		printf("%d", 7);
	}

	
	return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n;
        cin >> n;
        ll ans =0 ;
        for(i = 1; i <= n; i++){
            ll x;
            cin >> x;
            if(x % 2 == 1 && i % 2 == 1){
                ans++;
            }
        }
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 3604
var i,x,min,max:integer;n:integer;
{procedure       mo;
begin
        assign(input,'test.inp');reset(input);
        assign(output,'test.out');rewrite(output);
end;
procedure       dong;
begin
        close(input);close(output);
end;}
procedure       nhap;
begin
        readln(n);max:=0;min:=1001;
        for i:=1 to n do
                begin
                read(x);
                if x>max then max:=x;
                if x<min then min:=x;
                end;
end;
procedure       xuli;
begin
        writelN(max-min);
end;
begin
        //mo;
        nhap;
        xuli;
        //dong;
end.


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

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

    int l[N];
    int r[N];

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

    int M=0;

    for(int j=0; j<N; j++) {
        M += r[j] - l[j] + 1; 
    }

    cout << M << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

typedef pair<int, int> P;

map<P, int> side;
P data[205][205];
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1, 0, -1};
int a, b, c, n;

void print(){
  int ans[6];
  fill(ans, ans+6, 0);
  for(int i=0;i<205;i++) for(int j=0;j<205;j++) if(data[i][j].first) ans[data[i][j].second-1]++;
  cout << ans[0];
  for(int i=1;i<6;i++) cout << ' ' << ans[i];
  cout << endl;
}

void init(){
  side.clear();
  side[P(3, 5)] = side[P(5, 4)] = side[P(4, 2)] = side[P(2, 3)] = 1;
  side[P(3, 1)] = side[P(1, 4)] = side[P(4, 6)] = side[P(6, 3)] = 2;
  side[P(5, 1)] = side[P(1, 2)] = side[P(2, 6)] = side[P(6, 5)] = 3;
  side[P(1, 5)] = side[P(5, 6)] = side[P(6, 2)] = side[P(2, 1)] = 4;
  side[P(1, 3)] = side[P(6, 4)] = side[P(4, 1)] = side[P(3, 6)] = 5;
  side[P(5, 3)] = side[P(3, 2)] = side[P(2, 4)] = side[P(4, 5)] = 6;
}

void move(int idx){
  int ta = a, tb = b, tc = c;
  if(idx == 0){
    a = tb;
    b = 7-ta;
    c = tc;
  }else if(idx == 1){
    a = 7-tc;
    b = tb;
    c = ta;
  }else if(idx == 2){
    a = 7-tb;
    b = ta;
    c = tc;
  }else if(idx == 3){
    a = tc;
    b = tb;
    c = 7-ta;
  }
}

void calc(){
  int x = 100, y = 100;
  while(1){
    bool f = false;
    int idx, ny, nx;
    for(int k=6;k>3;k--){
      if(a == k) continue;
      else if(b == k) idx = 2;
      else if(c == k) idx = 1;
      else if(7-a == k) continue;
      else if(7-b == k) idx = 0;
      else if(7-c == k) idx = 3;
      ny = y + dy[idx];
      nx = x + dx[idx];
      if(data[y][x].first <= data[ny][nx].first) continue;
      f = true;
      break;
    }
    if(f){
      y = ny;
      x = nx;
      move(idx);
    }else{
      data[y][x].first++;
      data[y][x].second = a;
      return;
    }
  }
}


main(){
  init();
  while(cin >> n && n){
    fill(data[0], data[205], P(0, 0));
    for(int i=0;i<n;i++){
      cin >> a >> b;
      c = side[P(a, b)];
      calc();
    }
    print();
  }
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner cin = new  Scanner(System.in);
        int n, i;
        n = cin.nextInt();
        int[] A = new int[n];
        for (i = 0; i < n; i++) {
            A[i] = cin.nextInt();
        }
        int count = BubbleSort(A, n);
        for (i = 0; i < n - 1; i++) {
            System.out.print(A[i] + " ");
        }
        System.out.println(A[i] + "\n" + count);
    }
    static int BubbleSort(int[] A, int n) {
        int i = 0, j, count = 0;
        boolean flag = true;
        while (flag) {
            flag = false;
            for (j = n - 1; j > i; j--) {
                if (A[j] < A[j - 1]) {
                    int temp = A[j];
                    A[j] = A[j - 1];
                    A[j - 1] = temp;
                    flag = true;
                    count++;
                }
            }
            i++;
        }
        return count;
    }
}


Measured memory_bytes: 26264
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort(reverse=True)
    ans = []
    for i in range(1, n * 3, 2):
        ans.append(a[i])
        if len(ans) == n:
            print(sum(ans))
            exit()


if __name__ == '__main__':
    slove()


Measured memory_bytes: 107536
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
const int N = 1e5;

pii a[N];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);

    for (int i = 0; i < n; ++i)
        scanf("%d%d", &a[i].first, &a[i].second);

    sort(a, a + n);

    ll ans = 0;
    for (int i = 0; i < n; ++i)
    {
        if (m <= a[i].second)
        {
            ans += m * 1LL * a[i].first;
            m = 0;
            break;
        }
        else
        {
            ans += a[i].second * 1LL * a[i].first;
            m -= a[i].second;
        }
    }

    printf("%lld", ans);
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;

int main()
{
    int a[3];
    int sums=0;
    for(int i=0; i<3; i++){
        cin >> a[i];
        sums+=a[i];
    }
    if(sums>=22) cout << "bust" << endl;
    else cout << "win" << endl;




    return 0;
}

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

int main(){
   unsigned long long a,b,c,l,r;
   cin>>a>>b>>c;
   l=4*a*b,r=(c-a-b)*(c-a-b);
   if(c<=a+b) puts("No");
   else if(l<r)puts("Yes");else puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
using ll = long long;

#define     _test int _TC; cin >> _TC; while(_TC--)
#define     CS(x) cout << "Case " << x << ": ";
#define     precision(n) cout << fixed << setprecision(n);
#define     Clear(a, b) memset(a, b, sizeof(a))
#define     sq(x) ((x) * 1LL * (x))
#define     eb emplace_back
#define     all(_n) _n.begin(), _n.end()
#define     rall(_n) _n.rbegin(), _n.rend()
#define     endl "\n"
#define     show(x) cout << x << endl
#define     nl cout << endl
#define     sz(x) int(x.size())
#define     gcd(a, b) __gcd(a, b)
#define     lcm(a, b) (abs((a) * (b)) / gcd(a, b))
#define     parity(a, b) ((a&1) ^ (b&1))
#define     make_unique(x) sort(all((x))); (x).erase(unique(all((x))), (x).end())
#define     IN(a) for(auto &it : a) cin >> it

template <typename T> void print (T t){ for(const auto &it : t) cout << it << ' '; nl; }
template <typename T> using OS = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // order_of_key find_by_order

const    double Pi = acos(-1.0);
const    int Mod = 1e9 + 7;
const    int Inf = 1 << 30; // INT_MAX = (1LL << 31) -1 // Inf -> 1e9
const    int Maxx = 4010;

/************************************[Code Starts Here]************************************/


void _case()
{
    int n; cin >> n;
    string s; cin >> s;
    vector<int> R, B;
    map<int, bool> G;
    
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') R.eb(i);
        else if (s[i] == 'B') B.eb(i);
        else G[i] = 1;
    }
    
    ll ans = (ll)R.size() * G.size() * B.size();
    
    for (int r: R) {
        for (int b: B) {
            if ((r+b)%2 == 0 && G[(r+b)/2]) ans--;
            if (G[2*r - b]) ans--;
            if (G[2*b - r]) ans--;
        }
    }
    show(ans);
}

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    _case();
    return 0;
}




Measured memory_bytes: 4120
# region
import sys
import itertools

DEBUG = True if (len(sys.argv) > 1 and sys.argv[1] == "DEBUG") else False


def dp(value):
    if DEBUG:
        print(value)
    return


def input_text(split=" "):
    # 入力
    result = []
    while True:
        try:
            row = list(
                map(lambda x: int(x) if x.isdecimal() else x, input().split(split))
            )
            result.append(row)
        except EOFError:
            break
    return result


# endregion
it = input_text()

r = list(itertools.chain.from_iterable(it[1:]))
r_min = sys.maxsize
diff_max = -sys.maxsize

if len(r) == 0:
    print(0)
    sys.exit()

for rj in r:
    dif = rj - r_min
    if diff_max < dif:
        diff_max = dif
    if rj < r_min:
        r_min = rj

print(diff_max)



Measured memory_bytes: 35620
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //
        //Compute c1=new Compute();//計算系
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        int answer = 0;
        //String answer="No";
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int p[]=new int[n];

        for (int i=0;i<n;++i) { p[i]=sc.nextInt(); }

        for (int i=1;i<n-1;++i)
        {
            int a=Math.min(p[i-1],p[i+1]);
            int b=Math.max(p[i-1],p[i+1]);
            if(a<p[i] && b>p[i]){++count;}
        }
        answer=count;

        //出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        System.out.println(answer);
    }
}

Measured memory_bytes: 22608
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias P = Tuple!(int, "x", int, "y", int, "h");

void main()
{
    auto N = readln.chomp.to!int;
    P[] ps;
    ps.length = N;
    foreach (i; 0..N) {
        auto xyh = readln.split.to!(int[]);
        ps[i] = P(xyh[0], xyh[1], xyh[2]);
    }

    sort!"a.h > b.h"(ps);

    foreach (y; 0..101) {
        foreach (x; 0..101) {
            int h = -1;
            bool ok = true;
            foreach (p; ps) {
                auto ht = p.h + abs(x - p.x) + abs(y - p.y);
                if (h == -1) {
                    h = ht;
                } else if (p.h == 0) {
                    if (h > ht) {
                        ok = false;
                        break;
                    }
                } else {
                    if (h != ht) {
                        ok = false;
                        break;
                    }
                }
            }
            if (ok) {
                writefln("%d %d %d", x, y, h);
                return;
            }
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#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()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    rep(i, N) { cin >> A[i]; }

    ll ma = -INF;
    for (int i = N - 1; i > -1; i--) {
        if (i == N - 1)
            B[i] = -INF;
        else {
            B[i] = ma;
        }

        ma = max(ma, A[i]);
    }

    ll ans = -INF;
    rep(i, N) { ans = max(ans, B[i] - A[i]); }

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


Measured memory_bytes: 5952
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> x(n);
    for(int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        x[i] = {temp, i};
    }
    sort(x.begin(), x.end());
    vector<int> result(n);
    for(int i = 0; i < n; i++)
    {
        if(i < n / 2)
        {
            result[x[i].second] = x[n / 2].first;
        }else{
            result[x[i].second] = x[(n / 2) - 1].first;
        }
    }
    for(auto e : result)
    {
        cout << e << endl;
    }
    return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(int argc, char const *argv[])
{
	int n, t, a; cin >> n >> t >> a;
	vector<double> h(n); {
		rep(i, n) cin >> h[i];
	}

	vector<pair<double, int>> v;
	rep(i, n) {
		v.pb(mp(abs(((double)t - h[i] * 0.006) - a), i));
	}
	sort(all(v));

	printf("%d\n", v[0].second + 1);
	return 0;
}

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

using namespace std;

typedef long long int64;
int main()
{
  int H, W, N;

  cin >> H >> W >> N;

  set< pair< int, int > > pts;
  for(int i = 0; i < N; i++) {
    int y, x;
    cin >> y >> x;
    --x, --y;
    pts.emplace(x, y);
  }

  vector< int64 > proc(10, 0);
  proc[0] = 1LL * (H - 2) * (W - 2);
  set< pair< int, int > > finished;
  for(auto p : pts) {
    for(int i = -2; i <= 0; i++) {
      for(int j = -2; j <= 0; j++) {
        int nx = p.first + i, ny = p.second + j;
        if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
        if(finished.count({nx, ny})) continue;
        finished.insert({nx, ny});
        int sum = 0;

        bool flag = true;
        for(int k = 0; k < 3; k++) {
          for(int l = 0; l < 3; l++) {

            int nnx = nx + k, nny = ny + l;
            if(nnx < 0 || nnx >= W || nny < 0 || nny >= H) flag = false;
            if(pts.find({nnx, nny}) != pts.end()) ++sum;
          }
        }

        if(flag) {
          proc[sum]++;
          proc[0]--;
        }
      }
    }
  }

  for(int i = 0; i < 10; i++) {
    cout << proc[i] << endl;
  }
}

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

int main(){
    int d;
    cin >> d;
    vector<int> c(26);
    for(int i = 0; i < 26; i++) cin >> c[i];
    vector<vector<int>> s(d+1, vector<int>(26));
    for(int i = 1; i <= d; i++){
        for(int j = 0; j < 26; j++) cin >> s[i][j];
    }
    
    vector<int> last(26, 0);
    int ans = 0;
    for(int i = 1; i <= d; i++){
        int type = 0;
        for(int j = 0; j < 26; j++){
            if(s[i][type] < s[i][j]) type = j;
        }
        ans += s[i][type];
        last[type] = i;
        for(int j = 0; j < 26; j++){
            ans -= c[j] * (i - last[j]);
        }
        cout << type+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3668
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod=10**9+7

h,w=MI()
n=I()
colors=LI()
col=[]
for i in range(n):
    for j in range(colors[i]):
        col.append(i+1)
#print(col)
lis=[[0 for i in range(w)] for j in range(h)]
count=0
for i in range(h):
    for j in range(w):
        if i%2==0:
            k=j
        else:
            k=w-j-1
        lis[i][k]=col[count]
        count+=1
#print(lis)
for i in range(h):
    for j in range(w):
        print(lis[i][j],end=" ")
    print()

Measured memory_bytes: 4340
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
int N, W, H, S, T, grid[1000][1000];
signed main() {
  // そのまま全探索できます
  while (cin >> N, N) {
    cin >> W >> H;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        grid[i][j] = 0;
      }
    }
    for (int i = 0; i < N; i++) {
      int x, y; cin >> x >> y;
      grid[--y][--x] = 1;
    }
    cin >> S >> T;
    int ans = 0;
    for (int i = 0; i <= H-T; i++) {
      for (int j = 0; j <= W-S; j++) {
        int cnt = 0;
        for (int k = i; k < i+T; k++) {
          for (int l = j; l < j+S; l++) {
            cnt += grid[k][l];
          }
        }
        ans = max(ans, cnt);
      }
    }
    cout << ans << endl;
  }
}




Measured memory_bytes: 3480
#include <stdio.h>

int main(void) {
	int a, b;
	char ope;
	

	
	while(1){	scanf("%d %c %d", &a, &ope, &b);
	
	if(ope=='?')
	break;
	
		if(ope=='+')
		printf("%d\n", a+b);
		
		if(ope=='-')
		printf("%d\n", a-b);
		
		if(ope=='*')
		printf("%d\n", a*b);
		
		if(ope=='/')
		printf("%d\n", a/b);
		
	}	

	
	return 0;
}

Measured memory_bytes: 600
L1 = list(map(int, input().split()))
L2 = list(map(int, input().split()))
L3 = list(map(int, input().split()))
L = L1 + L2 + L3
N = int(input())
A = [0]*9
for _ in range(N):
  i = int(input())
  if i in L:
    A[L.index(i)] = 1
if sum(A[:3])==3 or sum(A[3:6])==3 or sum(A[6:])==3:
  print('Yes')
elif A[0]+A[3]+A[6]==3 or A[1]+A[4]+A[7]==3 or A[2]+A[5]+A[8]==3:
  print('Yes')
elif A[0]+A[4]+A[8]==3 or A[2]+A[4]+A[6]==3:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  ll dp[n];
  dp[0]=0;
  dp[1]=abs(arr[1]-arr[0]);
  for(int i=2;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i]),dp[i-2]+abs(arr[i]-arr[i-2]));
  }
  cout<<dp[n-1];
              return 0;
              }


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

int main() {
	int d;
	cin >> d;
	// Read in C (degree of losing satisfaction per contest)
	vector<int> c(26);
	rep(i, 26) {
		cin >> c[i];
	}
	// Read in S_ij (Increase in satisfaction per day per contest)
	vector<vector<int>> s(d, vector<int>(26));
	rep(i, d) {
		rep(j, 26) {
			cin >> s[i][j];
		}
	}
	// Read in t (contest held each day)
	// Read in last (last day in which a contest was held)
	vector<int> t (d);
	vector<vector<int>> last (d, vector<int> (26, 0));
	rep(i, d) {
		cin >> t[i];
		last[i][t[i] - 1] = i + 1;
	}
	rep2(i, 1, d - 1) {
		rep(j, 26) {
			last[i][j] = last[i][j] + ((last[i][j] == 0) ?last[i - 1][j] : 0);
		}
	}

	vector<int> v(d);
	int score = 0;
	for (int i = 0; i < d; i++) {
		score += s[i][t[i] - 1];
		rep(j, 26) {
			score -= c[j] * (i + 1 - last[i][j]);
		}
		v[i] = score;
	}
	rep(i, d) {
		cout << v[i] << "\n";
	}
	return 0;
}


Measured memory_bytes: 3560
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i = x;i<n;i++)
#define S(v) sort(v.begin(), v.end());
#define ff first
#define ss second



int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	cout<<(n>=30?"Yes":"No");
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a==5 && b==7 && c==5) {
			System.out.println("YES");
		}else if (a==7 && b==5 && c==5) {
			System.out.println("YES");
		}else if (a==5 && b==5 && c==7) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}

}

Measured memory_bytes: 22868
r, c = gets.split.map(&:to_i)
v = Array.new c + 1, 0
r.times do
  a = gets.split.map(&:to_i)
  a << a.inject(0, :+)
  puts a.join ' '
  (c + 1).times do |i|
    v[i] += a[i]
  end
end
puts v.join ' '

Measured memory_bytes: 9016
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int c = scanner.nextInt();
		//int ary[][]= new int[n][m];
		int ans= 0;
		int b[]= new int[m];
		for(int l = 0; l<m; l++) {
			b[l]= scanner.nextInt();
		}
		for(int s=0; s<n; s++) {
			int tmp = c;
			for(int t=0; t<m; t++) {
				//ary[s][t]= scanner.nextInt();
			tmp += b[t]*scanner.nextInt(); 
			}
			if(tmp>0)ans++;
			
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 25812
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;
#define int long long
int h,w,n;

const int dx[9] = {1, 1, 1, 0, 0, -1, -1, -1,0};
const int dy[9] = {0, 1, -1, 1, -1, 0, 1, -1,0};
map<pair<int,int>,int> mp;
int ans[10];
signed main(){
  cin>>h>>w>>n;
  int cnt=0;

  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;

    for(int j=0;j<9;j++){
      int xt=a+dx[j];
      int yt=b+dy[j];
      if(1<=xt && 1<=yt &&xt<h-1&&yt<w-1){
        // mp.insert(make_pair(xt,yt),);
        //cout<<"xt="<<xt<<" yt="<<yt<<endl;
        cnt++;
        mp[make_pair(xt,yt)]+=1;
      }
    }
  }
  dump(cnt);
  for(auto itr:mp){
    // cout<<itr.first.first<<" "<<itr.first.second<<endl;
    // cout<<itr.second<<endl;
     ans[itr.second]++;
  }
  int total=0;
  for(int i=1;i<10;i++){
    total+=ans[i];
  }
  cout<<(h-2)*(w-2)-total<<endl;
  for(int i=1;i<10;i++){
    cout<<ans[i]<<endl;
  }



}


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

#include <atcoder/all>
using namespace atcoder;

int main() {
  int n, m;
  cin >> n >> m;
  dsu d(n);
  while (m--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    d.merge(a, b);
  }
  cout << d.groups().size() - 1 << endl;
}


Measured memory_bytes: 8864
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N; cin >> N;
    vector<int> A(N); repp(i,0,N) cin >> A[i];

    bool res = true;
    repp(i,0,N) {
        if (A[i] %2 == 0) res &= A[i] % 3 == 0 || A[i] % 5 == 0;
    }
    if (res) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  int a, b, c;
  cin >> a >> b >> c;

  if (c >= a && c <= b) pr("Yes");
  else pr("No");


  return 0;
}


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

int n, m, ac[100000], wa[100000];

int main()
{
    cin >> n >> m;
    for (int in = 0; in < m; in++)
    {
        int x;
        cin >> x;
        x--;
        string s;
        cin >> s;

        if (!ac[x])
        {
            if (s == "WA") wa[x]++;
            else ac[x] = 1;
        }
    }

    int AC = 0, WA = 0;
    for (int i = 0; i < n; i++)
    {
        if (ac[i])
        {
            AC++;
            WA += wa[i];
        }
    }

    cout << AC << " " << WA << endl;
}

Measured memory_bytes: 4296
#include <stdio.h>
char st[200];
int a,b,c;
int main()
{
    scanf("%d%d%d",&a,&b,&c);
    for (int i=0;i<=a;i++)
    for (int j=0;j<=b;j++)
    {
        int temp=0;
        temp+=i*b;
        temp+=j*a;
        temp-=2*i*j;
        if (c==temp) {printf("Yes");return 0;}
    }
    printf("No");
}


Measured memory_bytes: 128