akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <ctime>
using namespace std;

int M;
int a[7];
int s, g;
int N[301];

bool isChecked[301];
vector<int> milestone[301];  //そのマスで出せばゴールにたどり着ける目を格納する

int iabs(int x){ return x >= 0 ? x : -x; }

bool search(int now){
	if (isChecked[now]) return false;
	else if (now == g)  return true;

	isChecked[now] = true;
	for (int dice = 1; dice <= 6; dice++){
		if (now + a[dice] <= M && search(now + a[dice] + N[now + a[dice]])){
			milestone[now].push_back(a[dice]);
		}
		if (now - a[dice] >= 1 && search(now - a[dice] + N[now - a[dice]])){
			milestone[now].push_back(-a[dice]);
		}
	}

	return milestone[now].size() > 0 ? true : false;
}

int main(){
	srand((unsigned int)time(NULL));
	cin >> M;
	for (int i = 1; i <= 6; i++){
		cin >> a[i];
	}
	cin >> s >> g;
	for (int i = 1; i <= M; i++){
		cin >> N[i];
	}
	bool canGoal = search(s);

	int now = s; //自分が今いるマスの番号
	for (;;){
		int dice;
		cin >> dice;

		bool found = false;
		for (vector<int>::iterator it = milestone[now].begin(); it != milestone[now].end(); it++){
			if (iabs(*it) == a[dice]){
				int pm = *it > 0 ? 1 : -1;
				now = now + pm * a[dice] + N[now + pm * a[dice]];
				cout << pm << endl;

				/*if (*it > 0){
					now = now + a[dice] + N[now + a[dice]];
					cout << 1 << endl;
				}
				else{
					now = now - a[dice] + N[now - a[dice]];
					cout << -1 << endl;
				}*/
				found = true;
				break;
			}
		}
		if(!found) cout << 0 << endl;
		cout.flush();

		if (now == g) return 0;
	}
	
	return 0;
}

Measured memory_bytes: 1304
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
double a[101];
double ave, minl;
int pos;

int main(){
    cin >> n;
    REP(i, n)cin >> a[i];
    REP(i, n)ave += a[i];
    ave /= n;
    minl = HINF<double>();
    REP(i, n){
        if(minl > abs(ave - a[i])){
            minl = abs(ave - a[i]);
            pos = i;
        }
    }
    cout << pos << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main(void){
	int n, m;
	cin >> n >> m;
	
	//1900*n*2^n/(2^n-1)
	cout << ((n-m)*100 + 1900*m)/(1/pow(2,m)) << endl;
	return 0;
}

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

using namespace std;

#define LL long long
#define int long long
#define fi first
#define se second
#define pll pair<LL, LL>
#define pii pair<LL, LL>

const LL MAXN = 3e3+5;
int N;
string s;
int mod = 1e9+7;
int dp[MAXN][MAXN];
int sum[MAXN][MAXN];

signed main() {
    cin >> N;
    cin >> s;
    dp[1][1] = 1;
    sum[1][1] = 1;
    for (int i = 2; i <= N; i++) {
        for (int j = 1; j <= i; j++) {
            if (s[i-2] == '<') {
                // 1 ~ j-1
                dp[i][j] = (dp[i][j] + sum[i-1][j-1]) % mod;
            } else {
                // j ~ i-1
                if (i-1 >= j)
                    dp[i][j] = (dp[i][j] + (sum[i-1][i-1] - sum[i-1][j-1] + mod) % mod) % mod;
            }
            //cout << dp[i][j] << endl;
            sum[i][j] = (sum[i][j-1] + dp[i][j]) % mod;
        } 
    }
    cout << sum[N][N] << endl;
    return 0;
}

Measured memory_bytes: 139648
n = int(input())
x = list(map(int,input().split()))

phy = []
tmp = 0
max1 = 0
count = 0

for i in range(101):
    phy.append(i*i)

for j in range(1,max(x)+1):
    for k in range(n):
        tmp += phy[abs((j-x[k]))]
    if(max1 > tmp or count == 0):
        max1 = tmp
    count += 1
    tmp = 0

print(max1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
 
typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const int N = 703, inf = 1e9;
int n, m, g[N][N], col[N];
vi adj[N];
 
int k, cnt[2][N];
 
void dfs(int v) {
	cnt[col[v]][k]++;
	for (int to : adj[v]) {
		if (col[to] != -1 && col[to] != 1 - col[v]) {
			cout << -1;
			exit(0);
		}
		if (col[to] == -1) {
			col[to] = 1 - col[v];
			dfs(to);
		}
	}
}
 
int dp[N][N];
 
int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			g[i][j] = 1;
		}
	}
	for (int i = 1; i <= m; i++) {
		int x, y;
		cin >> x >> y;
		if (x > y) {
			swap(x, y);
		}
		g[x][y] = 0;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (g[i][j]) {
				adj[i].pb(j);
				adj[j].pb(i);
			}
		}
	}
	memset(& col, -1, sizeof(col));
	for (int i = 1; i <= n; i++) {
		if (col[i] == -1) {
			col[i] = 0;
			k++;
			dfs(i);
		}
	}
	dp[0][0] = 1;
	for (int i = 1; i <= k; i++) {
		for (int j = n; j >= 0; j--) {
			if (j >= cnt[0][i]) {
				dp[i][j] |= dp[i - 1][j - cnt[0][i]];
			}
			if (j >= cnt[1][i]) {
				dp[i][j] |= dp[i - 1][j - cnt[1][i]];
			}
		}
	}
	int ans = inf;
	for (int i = 0; i <= n; i++) {
		if (dp[k][i]) {
			ans = min(ans, (i * (i - 1)) / 2 + ((n - i) * (n - i - 1)) / 2);
		}
	}
	cout << ans;
}


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

int main()
{
    int n;
    scanf("%d",&n);
    int ci=0;
    for(;n>=1;n--)
    {
        int k=0;
        int h=n;
        while(h!=0)
        {
            h=h/10;
            k++;
        }
        if(k%2!=0)
            ci++;
    }
    printf("%d\n",ci);
    return 0;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
  x <- readLn
  print $ solve x

solve :: Int -> Int
solve x = q1 * 1000 + q2 * 5
  where
    (q1, r1) = x `divMod` 500
    q2 = r1 `div` 5


Measured memory_bytes: 508
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main {

  class UnionFind(val n: Int) {

    sealed trait Node

    final case class Root(count: Int, rank: Int) extends Node

    final case class NonRoot(parentIndex: Int) extends Node

    // TODO ArrayBufferではなくArrayでいいはず
    private val nodes: Array[Node] = Array.fill(n)(Root(count = 1, rank = 0))

    private def rootNode(index: Int): (Int, Root) = {
      nodes(index) match {
        case root: Root => (index, root) // nodes(index) == root
        case nonRoot: NonRoot =>
          val (rootIndex, root) = rootNode(nonRoot.parentIndex)
          nodes(index) = NonRoot(parentIndex = rootIndex) // 経路圧縮
          (rootIndex, root)
      }
    }

    def numComponents(): Int = nodes.count(p = node => node.isInstanceOf[Root])

    private def root(index: Int): Int = rootNode(index)._1

    def sameCount(x: Int): Int = rootNode(x)._2.count

    def same(x: Int, y: Int): Boolean = root(x) == root(y)


    def unite(x: Int, y: Int): Unit = {
      if (same(x, y)) return

      val (xRootIndex, xRoot) = rootNode(x)
      val (yRootIndex, yRoot) = rootNode(y)

      if (xRoot.rank < yRoot.rank) {
        // xRootの親をyRootとする
        nodes(xRootIndex) = NonRoot(parentIndex = yRootIndex)
        nodes(yRootIndex) = yRoot.copy(count = xRoot.count + yRoot.count)
      } else {
        // yRootの親をxRootとする
        nodes(yRootIndex) = NonRoot(parentIndex = xRootIndex)
        val nextXRootRank = xRoot.rank + (if (xRoot.rank == yRoot.rank) 1 else 0)
        nodes(xRootIndex) = Root(count = xRoot.count + yRoot.count, rank = nextXRootRank)
      }
    }

  }

  case class Magic(x: Int, y: Int, z: Long)

  def read() = {
    val sc = new Scanner(System.in)
    val n, m = sc.nextInt()
    // 0-index化
    val magics = IndexedSeq.fill(m)(
      Magic(sc.nextInt() - 1, sc.nextInt() - 1, sc.nextLong()))
    (n, m, magics)
  }


  def solve(n: Int, m: Int, magics: IndexedSeq[Magic]): Int = {
    val uf = new UnionFind(n)
    for (magic <- magics) {
      uf.unite(magic.x, magic.y)
    }
    uf.numComponents()
  }

  def main(args: Array[String]): Unit = {
    val (n, m, magics) = read()
    val result = solve(n, m, magics)
    println(result)
  }
}

Measured memory_bytes: 112068
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	static Scanner scanner;

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

	    int N=gi();
	    int[] W=new int[N];

        for(int i=0; i<N; i++) {
        	W[i]=gi();
        }

        int min=Integer.MAX_VALUE;        
        for (int i=1; i<N; i++) {
        	int T=i;
        	int b=0;
        	int a=0;
        	for (int j=0; j<i; j++) {
        		b+=W[j];
        	}
        	for (int j=i; j<N; j++) {
        		a+=W[j];
        	}
        	int z=Math.abs(b-a);
        	if(z<min) {
        		min=z;
        	}
        }
        

        System.out.print(min);

//        if (b>=1 && b<=12) {
//        	if(a>=1 && a<=12) {
//        	    System.out.println("AMBIGUOUS");
//        	} else {
//        		System.out.println("MMYY");
//        	}
//        }else {
//        	if(a>=1 && a<=12) {
//        	    System.out.println("YYMM");
//        	} else {
//        		System.out.println("NA");
//        	}
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35632
#include <stdio.h>
int main(void){
  int min = 1000000010 , max = 0,dif;
  int N,Ai[100],i;
  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf("%d",&Ai[i]);
    if(Ai[i]<min){
      min = Ai[i];
    }
    if(Ai[i]>max){
      max = Ai[i];
    }
  }

  dif = max-min;

  printf("%d",dif);
     
  return 0;
}

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

using namespace std;

#define ll long long

ll a, b, c, d;

ll func(ll c) {
    int add = (c - a%c)%c <= (b - a)%c;
    return (b - a) / c + add;
}

ll gcd(ll a, ll b) {
    while (b) {
        a%=b;
        swap(a, b);
    }
    return a;
}

int main()
{
    cin >> a >> b >> c >> d;
    cout << b - a + 1 - (func(c) + func(d) - func(c*d/gcd(c, d)));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

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

int dp[100][10];

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

	ll K; cin >> K;
	K--;

	for (int i = 0; i < 10; i++) { dp[0][i] = 1; }
	for (int j = 1; j < 100; j++) {
		for (int i = 0; i < 10; i++) {
			dp[j][i] = dp[j - 1][i];
		}
		for (int i = 0; i < 9; i++) {
			dp[j][i] += dp[j - 1][i + 1];
			dp[j][i + 1] += dp[j - 1][i];
		}
	}
	for (int digit = 0; digit < 100; digit++) {
		ll sum = 0;
		for (int i = 1; i < 10; i++) {
			sum += dp[digit][i];
		}
		if (K < sum) {
			string ans;
			for (int d = digit; d >= 0; d--) {
				if (d == digit) {
					for (int i = 1; i < 10; i++) {
						if (K < dp[d][i]) { ans.push_back('0' + i); break; }
						K -= dp[d][i];
					}
				}
				else {
					for (int i = max(0, ans.back() - '0' - 1); i <= min(9, ans.back() - '0' + 1); i++) {
						if (K < dp[d][i]) { ans.push_back('0' + i); break; }
						K -= dp[d][i];
					}
				}
			}
			cout << ans << endl;
			break;
		}
		else {
			K -= sum;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {
    
    int n, array[100] = {0},i;
    
    scanf("%d",&n);
    
    for (i = 0;i < n; i++) {
        scanf("%d",&array[i]);
    }
    
    for (i = n-1; i >= 1; i--) {
        printf("%d ",array[i]);
    }

    printf("%d",array[0]);
    printf("\n");
    return 0;
}

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

using namespace std;

int main()
{
    int a,i,j=0;

    char A[51];

    cin>> a;
    
    getchar();
    
    cin>> A;

    for(i=0;i<a-2;i++)
    {
        if(A[i]=='A')
        {
            if(A[i+1] == 'B' && A[i+2] == 'C')
            {
                j++;
            }
        }
    }

    cout<< j<< endl;

    return 0;
}

Measured memory_bytes: 3616
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  n = InputLine.to_i
  a = InputLine.to_ia

  s = 0
  h = a[0]
  (1...n).each do |i|
    if h > a[i] then
      s += h - a[i]
    end
    h = a[i] if h < a[i]
  end

  puts s.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 30200
#include <iostream>
using namespace std;
using Int = long long;
int S(Int n)
{
    int s = 0;
    while (n) {
        s += n % 10;
        n /= 10;
    }
    return s;
}
Int P[16] = {1};
int main()
{
    for (int i = 1; i <= 15; i++) {
        P[i] = P[i-1] * 10;
    }
    int K;
    cin >> K;
    Int n = 1;
    for (int i = 0; i < K; i++) {
        for (int k = 0; n - S(n) * P[k] > 0; k++) {
            n += 9 * P[k];
        }
        cout << n << endl;
        n++;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
	import java.lang.Math;
    public class Main
	{
		public static void main(String args[])
		{
			Scanner scan = new Scanner(System.in);
			long a = scan.nextLong();
			long b = scan.nextLong();
			long k = scan.nextLong();
			//System.out.println(a);
			long temp=Math.min(a,k);
			a=a-temp;
			k=k-temp;
			temp=Math.min(b,k);
			b=b-temp;
			System.out.print(a);
			System.out.print(" ");
			System.out.print(b);
		}
    }

Measured memory_bytes: 23252
#include <iostream>
using namespace std;
int main(void){
    int s; //問題の得点
    int s_sum = 0; //10問の合計得点

    for(int i = 1; i <= 10; i++){
        cin >> s;
        s_sum += s;
    }
    cout << s_sum << endl;
}


Measured memory_bytes: 3056
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln         PIC X(400).
01 maxlen     PIC 9(10) VALUE 100 COMP.
01 cur        PIC 9(10) VALUE 1 COMP.
01 i          PIC 9(10) VALUE 1 COMP.
01 j          PIC 9(10) COMP.
01 len        PIC 9(10) COMP.
01 ans        PIC 9(10) VALUE ZERO.
01 zs         PIC Z(9)9.
01 n          PIC 9(10).
01 p1.
   03 p11 OCCURS 100 DEPENDING ON n.
      05 p    PIC S9(10).

PROCEDURE DIVISION.
  ACCEPT n.
  ACCEPT ln.
  MOVE n TO maxlen.
  PERFORM maxlen TIMES
    PERFORM VARYING j FROM cur BY 1 UNTIL ln(j:1) = SPACE
    END-PERFORM
    COMPUTE len = j - cur
    MOVE ln(cur:len) TO p(i)
    COMPUTE cur = j + 1
    ADD 1 TO i
  END-PERFORM.
  PERFORM VARYING i FROM 2 BY 1 UNTIL n - 1 < i
    IF p(i - 1) < p(i) AND p(i) < p(i + 1)
      ADD 1 TO ans
    ELSE
      IF p(i + 1) < p(i) AND p(i) < p(i - 1)
        ADD 1 TO ans
      END-IF
    END-IF
  END-PERFORM.
  MOVE ans TO zs.
  DISPLAY FUNCTION TRIM(zs).
  STOP RUN.


Measured memory_bytes: 3824
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>

using namespace std;

int main() {
	int n;
	char s[100];

	cin >> n;
	cin >> s;
	int ans = 0;

	for (int i = 0; i < n - 2; ++i) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
			ans += 1;
		}
	}
	cout << ans << endl;

}



Measured memory_bytes: 3524
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n, m = nm()

aa = nl()

mx = sum(aa)/(4*m)

a = sorted(aa)[::-1]


for i in range(m):
  if a[i] < mx:
    print('No')
    exit()
print('Yes')



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

int n,t[8][8];
string str;
 
int ch(int y,int x){
  if(0<=y&&y<=7&&0<=x&&x<=7)return t[y][x];
  return 0;
}
 
void bomb(int y,int x){
  t[y][x]=0;
  for(int i=0;i<=3;i++){
    if(ch(y+i,x)==1)bomb(y+i,x);
    if(ch(y-i,x)==1)bomb(y-i,x);
    if(ch(y,x+i)==1)bomb(y,x+i);
    if(ch(y,x-i)==1)bomb(y,x-i);
  }
}
 
int main(){
  int x,y;
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<8;j++){
      cin>>str;
      for(int k=0;k<8;k++)t[j][k]=str[k]-'0';
    }
    cin>>x>>y;
    bomb(y-1,x-1);
    cout<<"Data "<<i+1<<':'<<endl;
    for(int j=0;j<8;j++){
      for(int k=0;k<8;k++){
    cout<<t[j][k];
      }
      cout<<endl;
    }
  }
 
  return 0;
}


Measured memory_bytes: 3124
import java.util.Arrays;
import java.util.Scanner;



class Main{


   public static void main(String[] a){


	        Scanner sc = new Scanner(System.in);
	        int[] d = new int[10];

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

	        Arrays.sort(d);

	        for(int i = 9; i > 6 ; i--){
	        	System.out.println(d[i]);
	        }


     }



}

Measured memory_bytes: 26148
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int A,B,K;
    cin >> A >> B >> K;
    int t = K/A;
    int ans = B*t;
    cout << ans << endl;
}


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

int main() {
  long long n, a;
  cin >> n;
  bool have = true;
  vector<long long> vec(n);
  for(long long i = 0; i < n; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for(long long i = 0; i < n - 1; i++){
    if(vec.at(i) == vec.at(i+1)){
      have = false;
    }
  }

  if(have){
    cout << "YES";
  }
  else{
    cout << "NO";
  }
  return 0;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var infty = 100000 * 2
var scanner = bufio.NewScanner(os.Stdin)

func nextInt() (int, error) {
	scanner.Scan()
	return strconv.Atoi(scanner.Text())
}

func findMaximumSubarray(arr []int) int {
	currentMaxSum, maxSumContainsTail := -infty, -infty

	for j := range arr {
		if arr[j] > maxSumContainsTail+arr[j] {
			maxSumContainsTail = arr[j]
		} else {
			maxSumContainsTail += arr[j]
		}
		if currentMaxSum < maxSumContainsTail {
			currentMaxSum = maxSumContainsTail
		}

		// fmt.Println(arr[j], currentMaxSum, maxSumContainsTail)
	}
	return currentMaxSum
}

func main() {
	scanner.Split(bufio.ScanWords)
	for {
		size, _ := nextInt()
		if size == 0 {
			break
		}

		arr := make([]int, size)
		for i := range arr {
			n, _ := nextInt()
			arr[i] = n
		}

		maximumSum := findMaximumSubarray(arr)
		fmt.Println(maximumSum)
	}
}



Measured memory_bytes: 1108
#include <stdio.h>

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

int main(void)
{
    int k;
    scanf("%d",&k);

    int sum=0;

    for(int s=1;s<k+1;s++){
        for(int t=1;t<k+1;t++){
            for(int u=1;u<k+1;u++){
                int a;
                if(s>t){
                    a=gcd(s,t);
                }else{
                    a=gcd(t,s);
                }
                if(u>a){
                    sum+=gcd(u,a);
                }else{
                    sum+=gcd(a,u);
                }
            }
        }
    }
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>
 
#define MAX (10000000)
 
char prime[MAX + 1];
 
int main(void)
{
    int n, i, j, num;
     
    prime[0] = prime[1] = 0;
    for (i = 2; i <= MAX; i++){
        prime[i] = 1;
    }
     
    for (i = 2; i * i <= MAX; i++){
        for (j = i * i; j <= MAX; j += i){
            prime[j] = 0;
        }
    }
     
    while (scanf("%d", &n), n != 0){
	    i = n;
		while (1){
			if (prime[i] == 1 && prime[i-2] == 1 && prime[i-6] == 1 && prime[i-8] == 1){
				break;
			}
			
			i--;
		}
		
		printf("%d\n", i);
    }
     
    return (0);
}

Measured memory_bytes: 10364
N = int(input())
S = input()
sum = 0
r = 0
g = 0
b = 0

for i in range(N):
    if S[i] == "R":
        r+=1
    elif S[i] == "G":
        g+=1
    else:
        b+=1

sum = r*g*b

for i in range(N):
    for j in range(N):
        try:
            a = S[i]
            b = S[i+j]
            c = S[i+2*j]
            if a!=b and b!=c and c!=a:
                sum -= 1
        except:
            break

print(sum)


Measured memory_bytes: 9084
N=int(input())
import collections
import heapq
ab=[tuple(map(int,input().split())) for i in range(N-1)]
G=[set() for i in range(N)]
for a,b in ab:
  a-=1
  b-=1
  G[a].add(b)
  G[b].add(a)
q=collections.deque()

dis=[[-1]*N for i in range(2)]
dis[0][0]=0
q.append(0)
while(q):
  x=q.popleft()
  for y in G[x]:
    if dis[0][y]==-1:
      q.append(y)
      dis[0][y]=dis[0][x]+1
dis[1][N-1]=0
q.append(N-1)
while(q):
  x=q.popleft()
  for y in G[x]:
    if dis[1][y]==-1:
      q.append(y)
      dis[1][y]=dis[1][x]+1

hqF=[(0,0)]
hqS=[(0,N-1)]
colord=[False]*N

while(1):
  if len(hqF)==0:
    print("Snuke")
    exit(0)
  _,x = heapq.heappop(hqF)
  while(colord[x]):
    if hqF:
      _,x = heapq.heappop(hqF)
    else:
      print("Snuke")
      exit(0)
  colord[x]=True
  for y in G[x]:
    if colord[y]==False:
      heapq.heappush(hqF,(dis[1][y],y))

  if len(hqS)==0:
    print("Fennec")
    exit(0)
  _,x = heapq.heappop(hqS)
  while(colord[x]):
    if hqF:
      _,x = heapq.heappop(hqS)
    else:
      print("Fennec")
      exit(0)
  colord[x]=True
  for y in G[x]:
    if colord[y]==False:
      heapq.heappush(hqS,(dis[0][y],y))


Measured memory_bytes: 54936
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
ll dp[(ll)1e5+1] = {1};
ll pow(ll a, ll b){return (b ? (b % 2 ? a : 1) * pow(a * a % MOD, b / 2) % MOD : 1);}
ll comb(ll n, ll k){return (n < k ? 0 : dp[n] % MOD * pow(dp[n - k] * dp[k] % MOD, MOD - 2) % MOD);}
int main(){
	ll n; cin >> n;
	for(ll i = 1; i <= n + 1; ++i) dp[i] = i * dp[i - 1] % MOD;
	ll a[n + 1];
	for(ll i = 0; i <= n; ++i)cin >> a[i];
	ll b[n] = {};
	ll l, r;
	for(ll i = 0; i <= n; ++i){
		if(!b[a[i] - 1]){
			b[a[i] - 1] = i + 1;
		}else{
			l = b[a[i] - 1];
			r = i + 1;
			break;
		}
	}
	for(ll i = 1; i <= n + 1; ++i) cout << (comb(n + 1, i) - comb(n + 1 - (r - l + 1), i - 1) + MOD) % MOD << endl;
	return 0;
}

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

template<typename T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

constexpr int MAX_N = 100;
constexpr int MAX_W = 10'000;

int N, W;
int v[MAX_N], w[MAX_N];
int dp[MAX_N + 1][MAX_W + 1];

int main() {
  cin >> N >> W;
  for (int i{}; i < N; ++i) cin >> v[i] >> w[i];

  for (int i{}; i < N; ++i) {
    for (int j{}; j <= W; ++j) {
      dp[i + 1][j] = dp[i][j];
      if (j >= w[i])
        chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
    }
  }

  cout << dp[N][W] << endl;
  return 0;
}



Measured memory_bytes: 7016
from itertools import permutations
fact = [1]
N = int(input())
seq = [i for i in range(1, N+1)]
seq = list(permutations(seq))
dic = {}
for i in range(len(seq)):
  x = seq[i]
  dic[x] = i
p = tuple([int(c) for c in input().split()])
q = tuple([int(c) for c in input().split()])

P = dic[p]
Q = dic[q]
print(abs(P-Q))

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

int main(){
  int n;
  cin>> n;
  vector<int> b(n-1);
  for (int i=0; i<n-1; i++) cin>> b.at(i);
  
  vector<int> a(n);
  a.at(0)=b.at(0);
  for (int i=0; i<n-1; i++){
    int var=b.at(i);
    a.at(i+1)=var;
    if (a.at(i)>var) a.at(i)=var;
  }
  int sum=0;
  for (int i=0; i<n; i++) sum+=a.at(i);
  cout<< sum;
}

Measured memory_bytes: 256
/* B */
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans, cnt;

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

	int N, K;
	cin >> N >> K;

	vector<int> p(N);
	rep(i, N) {
		cin >> p[i];
	}

	sort(p.begin(), p.end());

	int ans = 0;
	rep(i, K) {
		ans += p[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <string>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#define pie 3.141592653589793238
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string n;
  cin >> n;
  
  if(n[1]=='B') cout << "ARC" << endl;
  else cout << "ABC" << endl;
  
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll a=0,b=0;
    for(ll i=0;i<n;i++){
        if(s[i]=='(') a++;
        else a--;
        if(a<0){
            a++;
            b++;
        }
    }
    for(ll i=0;i<b;i++) cout << '(';
    cout << s;
    for(ll i=0;i<a;i++) cout <<')';
}

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

using ll=long long; 


void solve(){
	int n;
	cin>>n;
	vector<int>a(n);
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	int ans=1;
	int ans1=1;
	for(int i=0; i<n; i++){
		ans1*=3;
		if(a[i]%2==0){
			ans*=2;
		}
	}
	cout<<ans1-ans<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
/*
    Problem 16
    https://atcoder.jp/contests/abc150/tasks/abc150_c
*/
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;
/* typedef */
typedef long long ll;
/* constant */
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N), v(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    for (int i = 0; i < N; i++) v[i] = i + 1;
    int indA, indB;
    int cnt = 0;
    do {
        bool canA = true;
        bool canB = true;
        for (int i = 0; i < N; i++)
            if (A[i] != v[i]) canA = false;
        for (int i = 0; i < N; i++)
            if (B[i] != v[i]) canB = false;
        if (canA) indA = cnt;
        if (canB) indB = cnt;
        cnt++;
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(indA - indB) << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			if (s.equals("Y")) {
				System.out.println("Four");
				return;
			}
		}
		System.out.println("Three");
		sc.close();
	}
}

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

int main() {
  int a,b;
  cin >> a;
  cin >> b;

  string s;
  if(a>b){
    for(int i =0; i<a; i++) s+=(char)b+((int)'0');
  }else{
    for(int i =0; i<b; i++) s+=(char)a+((int)'0');
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
# -*-coding: utf-8 -*-
N = int(input())
W = [0] * N
for i in range(N):
    W[i] = input()

flag = True
if N != len(set(W)):
    flag = False
if flag:
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            flag  = False
            break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll n;
double tol,ans;
void dfs(vector<pair<double,double> > &p,VI &vis,int s,int cnt,double sum){
	if(cnt==n){
		tol+=sum;
		ans++;
	}
	for(int i=0;i<n;i++){
		if(!vis[i]){
			vis[i] = 1;
			double dis = sqrt((p[s].fi-p[i].fi)*(p[s].fi-p[i].fi)+(p[s].se-p[i].se)*(p[s].se-p[i].se));
			dfs(p,vis,i,cnt+1,sum+dis);
			vis[i] = 0;
		}
	}
}
void solve(){
	cin>>n;
	vector<pair<double,double> > p;
	rep(i,0,n){
		double x,y;
		cin>>x>>y;
		p.pb({x,y});
	}
	rep(i,0,n)
	{
		VI vis(n,0);
		vis[i] = 1;
		dfs(p,vis,i,1,0.0);
	}
	printf("%.9f",tol/ans);
}
int main() {
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{

	public static void main(String[] args) {
        FastScanner in = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int d[][] = new int[n][2];
        for(int i=0;i<n;i++) {
        	d[i][0] = in.nextInt();
        	d[i][1] = in.nextInt();
        }
        boolean ans = false;
        for(int i=0;i<n-2;i++) {
        	if(d[i][0]==d[i][1]&&d[i+1][0]==d[i+1][1]&&d[i+2][0]==d[i+2][1]) {
        		ans = true; break;
        	}
        }
        if(ans) 
        	out.println("Yes");
        else
        	out.println("No");
        out.flush();
	}
	
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		
		String next() {
			while(!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				}catch(IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int a[] = new int[n];
			for(int i=0;i<n;i++) a[i] = nextInt();
			return a;
		}
		
		Integer[] readArray(long n) {
		    Integer a[] = new Integer[(int)n];
			for(int i=0;i<n;i++) a[i] = nextInt();
			return a;
		}
		
		long[] readArray(int n,long x) {
			long a[] = new long[n];
			for(int i=0;i<n;i++) a[i] = nextLong();
			return a;
		}
		
	}
	
	static class Pair implements Comparable<Pair> {
		int x, y;
		Pair(int a, int b){ x = a; y = b; }
		int getKey() { return x; }
		int getVal() { return y; }
		@Override
		public int compareTo(Pair o) {
			if(o.getVal() - this.getVal()>0)
				return -1;
			else if(o.getVal() - this.getVal()<0)
				return 1;
			else 
				return 0;
		}
		
	}
	
	static boolean arrayEquals(char a[], char b[]) {
		int n = a.length;
		boolean verdict = true;
		for(int i=0;i<n;i++) {
			if(a[i]!=b[i]) {
				verdict = false;break;
			}
		}
		return verdict;
	}
	
	static long lcm(long a, long b) {
		return (a*b)/gcd(a,b);
	}
	
	static long gcd(long a, long b) {
		if(b==0) return a;
		else return gcd(b,a%b);
	}
	
	static long hashInt(int x,int y) {
		return x*(1_000_000_000L)+y;
	}
}



Measured memory_bytes: 33000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            WriteLine((48 - cin.ReadInt));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 11220
void main()
{
    long n = readln.chomp.to!long;

    string digits = "0357";
    long cnt;
    foreach (i; 0 .. 1000000)
    {
        long x = i;
        long len;
        string nums;
        while (x)
        {
            ++len;
            nums ~= digits[x%4];
            x /= 4;
        }

        long num;
        foreach_reverse (j, c; nums)
        {
            num += (c - '0') * 10 ^^ j;
        }
        if (num > n) break;

        if (!nums.canFind('0')
            && nums.canFind('3')
            && nums.canFind('5')
            && nums.canFind('7'))
            ++cnt;
    }

    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 1276
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long mod = 1000000007;

template<typename T>
void max_self(T& a, T b)
{
	a = max(a, b);
}
int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++)
		cin >> a[i];
	vvi dp(h + 1, vi(w + 1));
	dp[0][0] = 1;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
		{
			if (a[i][j] == '#')
				continue;
			dp[i + 1][j] = (dp[i + 1][j]+ dp[i][j]) % mod;
			dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % mod;
		}
	cout << dp[h - 1][w - 1];
	return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll ans = 0;
    rep(i,1,n+1){
        if(i%3==0&&i%5==0);
        else if(i%3==0);
        else if(i%5==0);
        else ans += i;
    }
    cout << ans << endl;
}

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

const int N = 29, M = 29;

int b[ M ];
int a[ N ][ M ];

int main(){
    int n, m, c, res = 0, count = 0;

    cin >> n >> m >> c;

    for( int i = 0; i < m; i++ )
        cin >> b[ i ];

    for( int i = 0; i < n; i++ ){
        for( int j = 0; j < m; j++ )
            cin >> a[ i ][ j ];
    }

    for( int i = 0; i < n; i++ ){
        res = c;

        for( int j = 0; j < m; j++ )
            res += a[ i ][ j ] * b[ j ];

        if( res > 0 )
            count++;
    }
    cout << count << endl;

    return 0;
}

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

using namespace std;
int main(void){
    // Here your code !
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c == 2*max(a,max(b,c))){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int n;
  cin >> n;
  cout << (n+1)/2 << endl;
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n , ans;
int v[MAXX];
int c[MAXX];

int main()
{
    _FastIO;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    for(int i = 0; i < n; i++){
        cin >> c[i];
        ans += (max(0 , (v[i] - c[i])));
    }
    cout << ans << endl;
    return 0;
}


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

int ri() {
    int n;
    scanf("%d", &n);
    return n;
}

struct CHT {
	typedef std::pair<int64_t, int64_t> Line;
	std::deque<Line> lines;
	bool check(Line r0, Line r1, Line r2) {
		return (r0.second - r1.second) * (r1.first - r2.first) > (r1.second - r2.second) * (r0.first - r1.first);
	}
	int64_t calc(Line line, int64_t x) { return x * line.first + line.second; }
	void add(Line line) {
		while (lines.size() >= 2 && !check(lines[lines.size() - 2], lines.back(), line)) lines.pop_back();
		lines.push_back(line);
	}
	int64_t get_minimum(int64_t x) {
		while (lines.size() >= 2 && calc(lines[0], x) >= calc(lines[1], x)) lines.pop_front();
		return calc(lines[0], x);
	}
};

int main() {
	int n = ri();
	int64_t c;
	std::cin >> c;
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	for (int i = n - 1; i >= 0; i--) a[i] -= a[0];
	CHT cht;
	cht.add({0, 0});
	for (int i = 1; i < n; i++) {
		int64_t cur = cht.get_minimum(a[i]) + c + (int64_t) a[i] * a[i];
		if (i == n - 1) {
			std::cout << cur << std::endl;
			return 0;
		}
		cht.add({-2 * a[i], cur + (int64_t) a[i] * a[i]});
	}
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  REP(i,N) cin >> A[i] >> B[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  ll ans;
  if (N%2==1) {
    ans = B[N/2] - A[N/2] + 1;
  } else {
    ans = B[N/2-1] + B[N/2] - A[N/2-1] - A[N/2] + 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define rep(i,n) for (int i = 0; i < (n); ++i)

const ll MOD = 1000000007;

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

    if ( n == 1) cout << "Hello World" << endl;
    else if ( n == 2 ) {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define K 2000001
#define INF 0.000001

void maxHeapify(int);
void insert(int *,int);
int extractMax(int *);
void Increasekey(int *,int,int);

int S[K];
int A[K];
int h=0;

int main(){
  char order[8];
  int i,key,count=0;

  while(1){
    scanf("%s",order);
    if(order[0]=='i') {
      scanf("%d",&key);
      insert(A,key);
    }
    else if(order[0]=='e' && order[1]=='x') {
        S[count]=extractMax(A);
        count++;
    }
    else break;
  }

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

  return 0;
}

void maxHeapify(int i){
  int l,r,largest,swap;

  if(h>=2*i)l=2*i; 
  else l=2000000001;  
    
  if(h>=2*i+1) r=2*i+1;
  else r=2000000001;

    if(l<=h && A[l]>A[i]) largest = l;

    else largest = i;

    if(r<=h && A[r]>A[largest]) largest = r;

    if(largest != i) {
       swap = A[i];
       A[i] = A[largest];
       A[largest] = swap;
       maxHeapify(largest);
    }
    else return;

}

int extractMax(int *A){
  int max;
  if(h<1) fprintf(stderr,"heap underflow\n");
 
  max = A[1];
  A[1] = A[h];
  h--;
  maxHeapify(1);

  return max;
}

void insert(int *A,int key){
  h++;
  A[h] = -INF;
  Increasekey(A,h,key);
}

void Increasekey(int *A,int i,int key){
  int swap;

  if(key<A[i]) fprintf(stderr,"new key is smaller than current key\n");
  
  A[i] = key;
  while(i>1 && A[i/2]<A[i]){
    swap = A[i/2];
    A[i/2] = A[i];
    A[i] = swap;
    i = i/2;
  }
}


 

Measured memory_bytes: 8788
#include<bits/stdc++.h>
using namespace std;
void solve(int l, int r, int L, int R, int n)
{
    while(l < 0) l += n;
    while(r < l) r += n;
    int mid = (l + r) /2;
    cout << mid % n << endl;
    string S;
    cin >> S;
    if (S=="Vacant") return;
    int W = 0;
    if(S[0]=='M') W =1;
    else W = 0;
    if((W-L+2)%2==(mid-l)%2) solve(mid+1,r,1-W,R,n);
    else solve(l,mid-1,L,1-W,n);

}
main()
{
int n;
cin >> n;
int L,M;
cout << 0 << endl;
string S;
cin >> S;
if (S=="Vacant") return 0;
if(S=="Male") L=1; else L =0;
cout << n/2 << endl;
cin >> S;
if (S=="Vacant") return 0;
if(S=="Male") M=1; else M =0;
if((M+L)%2==(n/2)%2) solve(n/2,0,M,L,n);
else solve(0,n/2,L,M,n);
}
/*
0 M
1 F
2 M
3 F
4 V
*/


Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mxn= 5e5+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int dp[mxn];
int call(int s){
    if(s==0)return 1;
    if(s<=2)return 0;
    if(dp[s]!=-1)return dp[s];
    int &ans=dp[s]=0;
    for(int i=3;i<=s;i++){
        ans=ans+call(s-i);
        ans=ans%mod;
    }
    return ans;
}
int main(){
    rishabh();
    int s;
    cin>>s;
    memset(dp,-1,sizeof(dp));
    cout<<call(s);
}

Measured memory_bytes: 5496
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        
        int dp[] = new int[N];
        
        for(int i = 1; i < N; i++) {
        	for(int j = i + 1 ; j <= N; j++) {
        		int normal = j - i;
        		int warp = Math.abs(X - i) + 1 + Math.abs(Y - j);
        		int cost = normal > warp ? warp : normal;
        		
        		dp[cost] ++;
        	}
        }
        
        for(int i = 1 ; i< N ; i++)
        	System.out.println(dp[i]);
	}
}


Measured memory_bytes: 22484
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

int main() {
	int n;
	cin >> n;
	int r, t;
	for (int i = 0; i < n; i++) {
		int r, t;
		cin >> r >> t;
		if (r % 100 == 0 && t % 30 == 0) {
			cout << (r / 100) + (t / 30) * 5 << endl;
		}
		else if (r % 100 == 0) {
			cout << (r / 100) + (t / 30) * 5 << " ";
			cout << (r / 100) + ((t + 29) / 30) * 5 << endl;
		}
		else if (t % 30 == 0) {
			cout << (r / 100) + (t / 30) * 5 << " ";
			cout << (r + 99) / 100 + (t / 30) * 5 << endl;
		}
		else {
			cout << (r / 100) + (t / 30) * 5 << " ";
			cout << (r + 99) / 100 + (t / 30) * 5 << " ";
			cout << (r / 100) + ((t + 29) / 30) * 5 << " ";
			cout << (r + 99) / 100 + ((t + 29) / 30) * 5 << endl;
		}
	}
}

Measured memory_bytes: 3116
n = gets.to_i
a = gets.split.map &:to_i

cnt = 0
flag = true
while flag
  flag = false
  (n - 1).downto(1) do |j|
    if a[j] < a[j - 1]
      a[j], a[j - 1] = a[j - 1], a[j]
      cnt += 1
      flag = true
    end
  end
end

puts a.join(" ")
puts cnt


Measured memory_bytes: 6864
n=int(input())
lis=[input()]
count=0
for i in range(0,n-1):
  word=input()
  if not word in lis:
    if lis[i][-1]==word[0]:
      count+=1
  lis.append(word)
if count==n-1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060