akhauriyash/Code-Regression huggingface dataset:
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair

 
int main(){
  CIN(n,y);
  REP(i,n+1){
    REP(j,n+1-i){
      int val = n - i - j;
      if( 10000*i + 5000 * j + 1000 * val  == y){
        SCOUT(i);SCOUT(j);COUT(val);
        return 0;
      }
    }
  }
  EN(-1 -1 -1);

  return 0;
}

Measured memory_bytes: 256
N, K = gets.split.map(&:to_i)
H = gets.split.map(&:to_i)
dp = []

N.times do |i|
  if i == 0
    dp << 0
  else
    min = 1000000000
    (1..i).each do |j|
      break if j > K
      tmp = dp[i - j] + (H[i] - H[i - j]).abs
      min = tmp if tmp < min
    end
    dp << min
  end
end

puts dp[N - 1]


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

signed main() {
    string str;
    cin >> str;
    int N = 0;
    for (auto e : str)
        N += e - '0';
    if (N % 9)
        cout << "No";
    else
        cout << "Yes";
    cout << endl;
    system("pause");
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    map<string, int> cnt;
    rep(i, n) {
        string s;
        cin >> s;
        cnt[s]++;
    }
    for (string str : {"AC", "WA", "TLE", "RE"})
    {
        cout << str << " x " << cnt[str] << endl;
    }
    return 0;
}

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

public class Main {

    public static void main(String[] args){
	Scanner stdin = new Scanner(System.in);
	int[] num = new int[10];
	for(int i = 0; i < num.length; i++){
	    num[i] = stdin.nextInt();
	}
	Arrays.sort(num);
	for(int i = 1; i <= 3; i++){
	    System.out.println(num[num.length - i]);
	}
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s=="Sunny"){
        cout << "Cloudy" << endl;
    }else if(s=="Cloudy"){
        cout << "Rainy" << endl;
    }else if(s=="Rainy"){
        cout << "Sunny" << endl;
    }
    return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int w, a, b;
    cin >> w >> a >> b;
 
    if(b+w < a){
        cout << a-(b+w) << endl;
    }else if(b > a+w){
        cout << b-(a+w) << endl;
    }else{
        cout << 0 << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        long a = sc.nextLong();
        long v = sc.nextLong();
        long b = sc.nextLong();
        long w = sc.nextLong();
        long t = sc.nextLong();
        if(v <= w){
            System.out.println("NO");
        }else{
            System.out.println((double)(Math.abs(a-b))/(double)(v-w) <= t ? "YES" : "NO");
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25388
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>

bool sort_pair( std::pair< int64_t, int64_t > origin, std::pair< int64_t, int64_t > another )
{
    return origin.first > another.first;
}

int main()
{
    int64_t a,b,c,d;
    std::cin>> a;
    bool dd = false;

    for( int i = 1; i <= a; i++ )
    {
        b = i * 1.08;

        if( b == a )
        {
            dd = true;
            b = i;
            break;
        }
    }

    if( dd )
    {
        std::cout<< b;
    }
    else
    {
        std::cout<< ":(";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define fl float
#define db double
#define ii pair<ll,ll>
#define pii pair<ii,ii>
#define ford(i,a,b) for(int i=a;i<=b;i++)
#define foru(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,a,b) for(int i=a;i<b;i++)
#define oo 10000000000001
#define ooo -1000000000001
#define bost  ios_base::sync_with_stdio(false); cin.tie(0);
int const maxn=int(1e5+5);
int n,a[maxn];
int main()
{
    bost
    cin>>n;
    ford(i,1,n) cin>>a[i];
    sort(a+1,a+n+1);
    int chia1=a[n/2];
    int chia2=a[n/2+1];
    cout<<chia2-chia1;
    return 0;
}


Measured memory_bytes: 640
void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], m = tmp[1];
    int[] road = new int[n];
    foreach (i; 0 .. m) {
        tmp = readln.split.to!(int[]);
        int a = tmp[0] - 1, b = tmp[1] - 1;
        ++road[a], ++road[b];
    }
    foreach (x; road) {
        x.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: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	
    public static void main(String[] args) throws IOException {
    	Scanner s = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] input;
		char ch = s.next().charAt(0);
		if(ch >= 'A' && ch <= 'Z') {
			out.print('A');
		} else {
			out.print('a');
		}
		out.flush();
		out.close();
    }
}


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

int main(){
  int h, w;
  cin >> h >> w;
  for(int i=0; i<w+2; i++)cout << '#';
  cout << endl;
  for(int i=0; i<h; i++){
    cout << '#';
    for(int j=0; j<w; j++){
      char a;
      cin >> a;
      cout << a;
    }
    cout << '#' << endl;
  }
  for(int i=0; i<w+2; i++)cout << '#';
  return 0;
}

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


int main()
{
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i, N) cin >> d[i];
  int Sum = 0;

  rep(i,N){
    rep(j,N){
      if(i==j)
        continue;
      Sum += d[i] * d[j];
    }
  }
  cout << Sum/2 << endl;
  return 0;
}


Measured memory_bytes: 3624
# coding:UTF-8
import sys
from math import factorial

MOD = 998244353
INF = 10000000000

def main():
    n, k = list(map(int, input().split()))  # スペース区切り連続数字
    lrList = [list(map(int, input().split())) for _ in range(k)]  # スペース区切り連続数字(行列)

    s = []
    for l, r in lrList:
        for i in range(l, r+1):
            s.append(i)
    s.sort()

    sum = [0] * (n + 1)
    Interm = [0] * (2 * n + 1)
    sum[1] = 1
    for i in range(1, n):
        for j in range(k):
            l, r = lrList[j][0], lrList[j][1]
            Interm[i+l] += sum[i]
            Interm[i+r+1] -= sum[i]
        sum[i+1] = (sum[i] + Interm[i+1]) % MOD

    # result = Interm[n]
    result = (sum[n] - sum[n-1]) % MOD
    # ------ 出力 ------#
    print("{}".format(result))

if __name__ == '__main__':
    main()


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

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}

//......................................@uthor_Alx..............................................


   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  //aint n=int_v(read());
	        		  Set<Integer> ss=new HashSet<>();
	        		  int[] nk=int_arr();
	        		  for(int i=1;i<=nk[1];i++){
	        		  	int di=int_v(read());
	        		  	int[] arr=int_arr();
	        		  	for(int x:arr){ss.add(x);}
	        		  }
	        		  out.write(nk[0]-ss.size()+"");
	        	
	        		// if(n[0]>0){out.write("Yes");}
	        		 //else{out.write("No");}
                      out.flush();
	        		 
	}
}
	       
	          



	
  





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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

const int MOD=1e6+3;
int F[MOD], Finv[MOD];

long long fast_pow(long long a, long long b)
{
	long long ret=1;
	for(;b;b>>=1) {
		if(b&1) ret=(ret*a)%MOD;
		a=(a*a)%MOD;
	}
	return ret;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int Q, X, D, N;
	F[0]=Finv[0]=1;
	for(int i=1;i<MOD;i++) F[i]=(1LL*F[i-1]*i)%MOD;
	Finv[MOD-1]=fast_pow(F[MOD-1],MOD-2);
	for(int i=MOD-2;i;i--) Finv[i]=(1LL*(i+1)*Finv[i+1])%MOD;
	for(cin>>Q;Q;Q--) {
		cin>>X>>D>>N;
		if(D) {
			X=(1LL*X*fast_pow(D,MOD-2))%MOD;
			if(X+N-1>=MOD) cout<<"0\n";
			else {
				int ans=(1LL*F[X+N-1]*Finv[max(X-1,0)])%MOD;
				cout<<(1LL*ans*fast_pow(D,N))%MOD<<'\n';
			}
		}
		else cout<<fast_pow(X,N)<<'\n';
	}
	return 0;
}

Measured memory_bytes: 8704
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val a, b, c, d = sc.nextInt()
  val l = a + b
  val r = c + d
  if (l > r) {
    println("Left")
  } else if (l < r) {
    println("Right")
  } else {
    println("Balanced")
  }
}


Measured memory_bytes: 55292
#include <bits/stdc++.h>
using namespace std;
#define f(i, k, n) for (int i = k; i < n; i++)
#define r(i, k, n) for (int i = k; i >= n; i--)
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define len(s) s.size()
#define all(v) v.begin(), v.end()
#define tr(it, v) for (auto &it : v)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z) cout << #x << "=" << x << "," << #y << "=" << y << ","<< #z << "=" << z << endl
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<vi> vvi;
// =================

const int mod = 1e9;
const int N = 3e5 + 1;

vi g[N];
int A[N];

void impgraph(int n, int m)
{
    int i=0, u, v;
    while (m--)
    {
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par)
{
    A[u]=1;
    for (int v : g[u])
    {
        if (A[v])
        {
            continue;
        }
        dfs(v, par);
    }
}

void solve()
{
    int n,m; cin>>n>>m;
    impgraph(n,m);
    dfs(1,0);
    int cnt=0;
    f(i,1,n+1) {
        if(!A[i]) {
            dfs(i,0);
            cnt++;
        }
    }
    cout<<cnt;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t = 1;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 15060
from collections import defaultdict

def gcd(x, y):
    r = x % y
    while r:
        x, y, r = y, r, y%r
    return y
    
def main():
    n = int(input())
    al = defaultdict(lambda: 0)
    All = 0
    mod = 1000000007
    goods = dict()
    for i in range(n):
        a, b = map(int, input().split())
        if a == 0 and b == 0:
            All += 1
        elif b == 0:
            al["inf"] += 1
            goods["inf"] = "0"
        elif a == 0:
            al["0"] += 1
            goods["0"] = "inf"
        else:
            g = gcd(b, a)
            a_key = f"{a//g},{b//g}"
            if b//g < 0:
                good = f"{-b//g},{a//g}"
            else:
                good = f"{b//g},{-a//g}"
            goods[a_key] = good
            al[a_key] += 1
    ans = 1
    al = dict(al)
    done = set()
    ok = 0
    for k, v in al.items():
        if k in done:
            continue
        num = al.get(goods[k])
        done.add(goods[k])
        if num:
            ans *= pow(2, num, mod)+pow(2, v, mod)-1
            ans %= mod
        else:
            ok += v
    ans *= pow(2, ok, mod)
    ans += All - 1
    ans %= mod
    print(ans)
        
        
            
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 247476
#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
    int n;
    scanf("%d", &n);
    vi v(n);
    for(int i = 0; i < n; i++){
        scanf("%d", &v[i]);
    }
    int r = 0;
    int num = 1;
    for(int i = 0; i < n; i++){
        if(v[i] == num){
            num++;
        }else{
            r++;
        }
    }
    if(r == n)
        printf("-1\n");
    else
        printf("%d\n", r);
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String qLine = scanner.nextLine();
		String aLine = scanner.nextLine();
		
		int[] map = new int['z' - 'a' + 1];
		int[] remap = new int['z' - 'a' + 1];
		
		for(int i = 0;i<26;i++) {
			map[i]= -1;
			remap[i]= -1; 
		}
		
		for(int i = 0;i<qLine.length();i++) {
			if(map[qLine.charAt(i) - 'a'] < 0) {
				map[qLine.charAt(i) - 'a'] = aLine.charAt(i) - 'a';
			}else {
				if(map[qLine.charAt(i) - 'a'] != aLine.charAt(i) - 'a') {
					System.out.println("No");
					return;
				}
			}
			if(remap[aLine.charAt(i) - 'a'] < 0) {
				remap[aLine.charAt(i) - 'a'] = qLine.charAt(i) - 'a';
			}else {
				if(remap[aLine.charAt(i) - 'a'] != qLine.charAt(i) - 'a') {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
    }
}
    


Measured memory_bytes: 29800
#include<stdio.h>
#define AAA 100000000;

int min(int ,int );

int main(){
  int n,i,j,k,ori;
  int A[101];
  int B[101];
  int C[101][101];

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d%d",&A[i],&B[i]);
  for(i=0;i<n;i++)C[i][i]=0;

  for(j=1;j<n;j++){
    for(i=0;i<n-j;i++){
      if(i!=i+j) C[i][i+j]=AAA;
      for(k=i;k<i+j;k++){
        ori=C[i][k]+C[k+1][i+j]+A[i]*B[k]*B[i+j];
        C[i][i+j]=min(C[i][i+j],ori);
      }
    }
  }
 printf("%d\n",C[0][n-1]);

  return 0;
}

int min(int m,int n){
  if(m>n) return n;
  else return m;
}



Measured memory_bytes: 2052
#include<bits/stdc++.h>
#include <cstring>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int x;
    cin>>x;
    string s;
    map<char,ll>m;
    for (int i=0;i<x;i++){
        cin>>s;
        m[s[0]]++;
    }
    ll ans=0;
    ll y[5];
    y[0]=m['A'];
    y[1]=m['C'];
    y[2]=m['H'];
    y[3]=m['M'];
    y[4]=m['R'];
    for (int i=0;i<3;i++)
        for (int j=i+1;j<4;j++)
        for (int k=j+1;k<5;k++)
        ans+=y[i]*y[j]*y[k];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	foreach (line; stdin.byLine) {
		auto x = line.split.map!(to!int).array;
		if (x[0] == -1) break;

		auto a = [2, 0, 0];

		a[] -= x[];
		foreach_reverse(i; iota(1, 3)) {
			if (a[i] < 0) {
				a[i-1]--;
				a[i] += 60;
			}
		}
		writefln("%02d:%02d:%02d", a[0], a[1], a[2]);
		a[] *= 3;
		foreach_reverse(i; iota(1, 3)) {
			if (a[i] > 60) {
				a[i-1] += a[i] / 60;
				a[i] %= 60;
			}
		}
		writefln("%02d:%02d:%02d", a[0], a[1], a[2]);
	}
}

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

typedef long long ll;


void solve(std::string S){
  int ans = 0;
  for (int i = 0; i < 4; i++)
  {
    ans += (S[i] == '+') ? 1 : -1;
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b)-1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep(i, n) for(int i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T>& p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T>& vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
constexpr ll MOD = 1000000007;

constexpr ll MAX = 1000000;
ll dp[MAX+1]; // 1~nまでで長さmの総数
ll dsum[MAX+1];

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

    dp[0] = 0;
    dsum[0] = 0;
    dp[1] = n;
    dsum[1] = n;
    for(ll i = 2; i <= n; i++){
        ll sum = 0;
        if(i >= 3){
            sum = (n-i+2)%MOD;
        } else {
            sum = n-1;
        }
        sum += ((n-1)*(n-1))%MOD;
        sum = sum % MOD;
        sum += dsum[i-1];
        sum = sum % MOD;
        sum = (sum +MOD -dp[i-2]) % MOD;
        dp[i] = sum;
        dsum[i] = (dsum[i-1] + sum) % MOD;
    }
    cout << dp[n] << endl;
    return 0;
}


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

signed main() {
  int n;
  cin>>n;
  int a[n],b[n],c[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-1;i++)cin>>c[i];
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=b[a[i]-1];
    if(i>0&&a[i-1]==a[i]-1)ans+=c[a[i-1]-1];
  }
  cout<<ans;


 


    return 0;
}


Measured memory_bytes: 256
N, M = gets.split(" ").map(&:to_i)
ary = Array.new(N + 1) {Array.new}
M.times do
    a, b = gets.split(" ").map(&:to_i)
    ary[a - 1] << b - 1
    ary[b - 1] << a - 1
end

ans = [0]
queue = [0]

until queue.empty?
    current = queue.shift
    ary[current].each do |to|
        next if ans[to]
        ans[to] = current + 1
        queue << to
    end
end

puts "Yes"
puts ans[1...N]


Measured memory_bytes: 33288
import java.io.PrintWriter;
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    private static Scanner in = new Scanner(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    public static class Node {
        private int num;
        private Node parent;
        private int counter;
        private List<Node> children;

        public Node(Node parent, int num) {
            this.num = num;
            this.parent = parent;
            this.children = new ArrayList<>();
        }

        public void setParent(Node parent) {
            this.parent = parent;
        }

        public void addChild(Node child) {
            this.children.add(child);
        }

    }

    private static void solve() {
        int n = in.nextInt();
        int q = in.nextInt();

        List<Node> nodes = new ArrayList<>();
        for (int i=1; i <= n; i++)
            nodes.add(new Node(null, i));

        for (int i=0; i < n-1; i++) {
            int a = in.nextInt();
            int b = in.nextInt();

            nodes.get(a - 1).addChild(nodes.get(b - 1));
            nodes.get(b - 1).addChild(nodes.get(a - 1));
        }

        for (int i=0; i < q; i++) {
            int p = in.nextInt();
            int x = in.nextInt();
            nodes.get(p - 1).counter += x;
        }

        Set<Integer> visited = new HashSet<>();
        Queue<Node> toVisit = new ArrayDeque<>();
        toVisit.add(nodes.get(0));
        visited.add(1);
        while (!toVisit.isEmpty()) {
            Node p = toVisit.poll();
            List<Node> toAdd = p.children;
            for (Node a : toAdd) {
                if (!visited.contains(a.num)) {
                    visited.add(p.num);
                    toVisit.add(a);
                    a.counter += p.counter;
                }
            }
        }

        out.println(
                nodes.stream().map(p -> String.valueOf(p.counter)).collect(Collectors.joining(" "))
        );
    }

}


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

int s, c=0;

int main() {
	cin >> s;

	if (s==1)
	{
		cout << 4 << endl;
		return 0;
	}
	if (s==2)
	{
		cout << 4 << endl;
		return 0;
	}

	bool flag=true;
	while(flag){
		c++;
		if (s%2)
		{
			if (s==1)
			{
				cout << c+1 << endl;
				return 0;
			} else {
				s = 3*s +1;
			}
		} else {
			s /= 2;
		}
	}
}

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

typedef long long ll;
 
int main(){
  int n; cin >> n;
  ll r[100];
  r[0] = 2;
  r[1] = 1;
  for(int i=2; i<=n; i++){
    r[i] = r[i-1] + r[i-2];
  }
  cout << r[n] << endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

int main() {
	int n,a,b;
	cin >> n >> a >> b;
	cout << min(a,b) << " " << max(0,(a+b)-n) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] p = new int[n];
    int[] q = new int[n];
    for (int i = 0; i < n; i++) {
      p[i] = sc.nextInt();
    }
    for (int i = 0; i < n; i++) {
      q[i] = sc.nextInt();
    }
    Main abc150C = new Main();
    System.out.println(abc150C.solve(n, p, q));
  }

  public Integer solve(int n, int[] p, int[] q) {
    return Math.abs(nth(p) - nth(q));
  }

  private Integer nth(int[] m) {
    Integer ret = 1;
    int[] mark = new int[m.length];
    int count;
    for (int i = 0; i < m.length; i++) {
      count = 0;
      for (int j = 0; j < m[i] - 1; j++) {
        if (mark[j] == 0) {
          count += 1;
        }
      }
      mark[m[i] - 1] = 1;
      ret += count * fact(m.length - i - 1);
    }
    return ret;
  }
  private int fact(int m) {
    int ret = 1;
    for(int i = 1; i <= m; i++ ){
      ret *= i;
    }
    return ret;
  }
}


Measured memory_bytes: 21840
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep2(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const ll INF = 100100100100;
const int MOD = 1000000007;

// 4 direction-vectors
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
  int H, W; cin >> H >> W;
  vector<string> field(H);
  for(int h = 0; h < H; ++h) cin >> field[h];

  int ans = -1;
  rep(h, H) rep(w, W){
    if (field[h][w] == '#') continue;

    vector<vector<int>> dist(H, vector<int>(W, -1));
    dist[h][w] = 0;

    queue<P> que;
    que.push(P(h, w));

    // BFS
    while (!que.empty()) {
      P v = que.front();
      que.pop();
      int h, w; tie(h, w) = v;

      // check 4 directions
      rep(dir, 4){
        int nh = h + dx[dir];
        int nw = w + dy[dir];

        // skip if outside the field or on a wall
        if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
        if (field[nh][nw] == '#') continue;

        if (dist[nh][nw] != -1) continue;
        dist[nh][nw] = dist[h][w] + 1;
        que.push(P(nh, nw));
      }
    }

    rep(i, H) rep(j, W) if(dist[i][j] > ans) ans = dist[i][j];
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    ll x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;;
    return 0;
}

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

int main(){
    int A,B,C,D,E,F;
    cin >> A >> B;
    C=A+B;
    D=A-B;
    E=A*B;
    F=max(D,E);
    cout << max(C,F) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main ( ) {
    int a, b;
    cin >> a >> b;
    
    int ans=0;
    int outlet=1;
    while ( outlet < b ) {
       --outlet;
       outlet += a;
       ++ans;
    }
  
    //cout << outlet << endl;
    cout << ans << endl;
}


Measured memory_bytes: 256
/*
 * ID: ALDS1_1_D
 * Problem: Maximum profit
 */

#include <stdio.h>

int main(void)
{
    int n, d, min;

    scanf("%d", &n);

    int i;
    scanf("%d", &d);
    min = d;
    scanf("%d", &d);
    int gain = d - min;
    int top_gain = gain;
    min = min < d ? min : d;
    for (i = 2; i < n; i++) {
        scanf("%d", &d);
        gain = d - min;
        //printf("%d - %d = %d\n", d, min, gain);
        top_gain = top_gain > gain ? top_gain : gain;
        min = min < d ? min : d;
    } 
    printf("%d\n", top_gain);

    return 0;
}



Measured memory_bytes: 2108
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    System.out.print(s.charAt(0));
    System.out.print(s.length()-2);
    System.out.println(s.charAt(s.length()-1));
  }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    vector<ll> a(n);
    map<ll,ll> m;
    rep(i,n) cin>>a[i];
    rep(i,n) m[a[i]]++;
    ll res=0;
    for(auto itr=m.begin(); itr!=m.end(); itr++){
        if(itr->second>=2) res+=itr->second*(itr->second-1)/2;
    }
    rep(i,n){
        if(m[a[i]]<2) cout<<res<<endl;
        else{
            ll tmp=res-m[a[i]]*(m[a[i]]-1)/2;
            tmp+=(m[a[i]]-1)*(m[a[i]]-2)/2;
            cout<<tmp<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 11008
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;
int N;
long long A[200000];
long long max_height;
long long ans;


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

	max_height = 0;
	ans = 0;
	for (int i = 0; i < N; i++) {
		if (max_height < A[i]) {
			max_height = A[i];
		}
		else {
			ans += max_height - A[i];
		}
	}
	cout << ans;
}

Measured memory_bytes: 5124
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 200003
#define MOD 1000000007
using Graph=vector<vector<int>>;

int main(){
  int N;
  cin>>N;
  vector<ll> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }

  if(N%2==1){
    vector<vector<ll>> dp(N,vector<ll>(N,0));
    for(int i=0;i<N;i++){
      dp.at(i).at(i)=a.at(i);
    }
    for(int w=1;w<N;w++){
      for(int i=0;i+w<N;i++){
        if(w%2==1){
          dp.at(i).at(i+w)=min<ll>(dp.at(i).at(i+w-1)-a.at(i+w),dp.at(i+1).at(i+w)-a.at(i));
        }else{
          dp.at(i).at(i+w)=max<ll>(dp.at(i).at(i+w-1)+a.at(i+w),dp.at(i+1).at(i+w)+a.at(i));
        }
      }
    }
    cout<<dp.at(0).at(N-1)<<endl;
  }else{
    vector<vector<ll>> dp(N,vector<ll>(N,0));
    for(int i=0;i<N;i++){
      dp.at(i).at(i)=-a.at(i);
    }
    for(int w=1;w<N;w++){
      for(int i=0;i+w<N;i++){
        if(w%2==1){
          dp.at(i).at(i+w)=max<ll>(dp.at(i).at(i+w-1)+a.at(i+w),dp.at(i+1).at(i+w)+a.at(i));
        }else{
          dp.at(i).at(i+w)=min<ll>(dp.at(i).at(i+w-1)-a.at(i+w),dp.at(i+1).at(i+w)-a.at(i));
        }
      }
    }
    cout<<dp.at(0).at(N-1)<<endl;
  }
}


Measured memory_bytes: 70656
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    _, b, c = LS()
    x = int(b[0] + c[0]) % 4
    if not x:
        print("YES")
    else:
        print("NO")
    return

#B
def B():
    II()
    a = LI()
    a.sort()
    print(a[-1]-a[0])
    return

#C
def C():
    II()
    a = LI()
    a = list(map(lambda x: x // 400, a))
    d = defaultdict(int)
    for ai in a:
        d[ai] += 1
    ans1 = 0
    ans2 = 0
    for key, value in d.items():
        if key <= 7:
            ans1 += 1
            ans2 += 1
        else:
            ans2 += value
    if ans1 == 0:
        ans1 = 1
    print(ans1, ans2)
    return

#D
def D():
    n = II()
    s = S()
    ans = deque(s[::1])
    f = 0
    for i in s:
        if i == "(":
            f += 1
        else:
            f -= 1
        if f < 0:
            ans.appendleft("(")
            f += 1
    ans.append(")" * f)
    print("".join(ans))

    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 39792
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########

H, W = l_inpl()
field = [ input() for _ in range(H) ]
sy, sx = 0, 0
gy, gx = H-1, W-1
def bfs(field, number_of_moves, sy, sx):
    queue = deque([[sy, sx]])
    number_of_moves[sy][sx] = 0
    while queue:
        y, x = queue.popleft()
        current_number_of_move = number_of_moves[y][x]
        for i in range(4):
            ny, nx = y + dy[i], x + dx[i]
            if inside(ny, nx, H, W) and \
                field[ny][nx] == "." and \
                number_of_moves[ny][nx] == -1:
                number_of_moves[ny][nx] = current_number_of_move + 1
                queue.append([ny, nx])
    return number_of_moves

number_of_moves = [ [-1] * W for _ in range(H) ]
number_of_moves = bfs(field, number_of_moves, sy, sx)
b_cnt = sum([ f.count("#") for f in field])

if number_of_moves[gy][gx] == -1:
    print(-1)
else:
    print(H*W-b_cnt-number_of_moves[gy][gx]-1)

Measured memory_bytes: 40432
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

    vec<int> l(N);
    rep(i, N) cin >> l[i];

    sort(all(l), greater<int>());
    int ans = 0;
    rep(i, K) ans += l[i];
    cout << ans << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a; i<=b; ++i)

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int,int> pi;
typedef tuple<bool, int, int> tp;
typedef vector<vector<int>> vv;
///-------------------------
vector<vector<int>> adj;
int n;


int main()
{
    Phuong_; /// <3333
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max({a*c, b*c, a*d, b*d});

    return 0;
}


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

#define ll long long
#define mp make_pair
#define rep(i, a, b) for(int i = (a);i <= (b);i++)
#define per(i, a, b) for(int i = (a);i >= (b);i--)

using namespace std;

typedef pair<int, int> pii;
typedef double db;
const int N = 1e6 + 50;
int n, k, a[N], ans = 0,  cnt;
set <int> s;
set <int>::iterator it;
inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){if(ch == '-') f = -1; ch = getchar();}
    while(ch >='0' && ch <='9'){x = (x<<3)+(x<<1)+(ch^48); ch = getchar();}
    return x*f;
}
void init(){
    n = read(); k = read();
    rep(i, 1, n) a[i] = read();
    rep(i, 1, k) s.insert(a[i]);
    rep(i, 2, n){
        if(a[i] > a[i-1]){
            int sum = 0;
            while(a[i] > a[i-1] && i <= n) i++, sum++;
            if(sum >= k-1) cnt ++;
        }
    }
    ans = n-k+1;
    int l = 1, r = k;
    while(l <= r && r <= n){
        r++;
        if(r > n) break;
        s.insert(a[r]);
        if(*(s.rbegin()) == a[r] && (*s.begin()) == a[l]) ans --;
        s.erase(a[l]); 
        l++;
    }
    if(!cnt) printf("%d\n", ans);
    else printf("%d\n", ans - cnt+1);
}
int main(){
    init();
    return 0;
}

Measured memory_bytes: 10368
#include <iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  string s;
  cin>>s;
  if(s.size()!=(a+b+1)){
    cout<<"No"<<endl;
    return 0;
  }
  for(int i=0;i<s.size();i++){
    if(i!=a){
      if(!(s[i]>='0' && s[i]<='9')){
        cout<<"No"<<endl;
        return 0;
      }
    }else if(s[i]!='-'){
      cout<<"No"<<endl;
      return 0;
    }
  }
      cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

def main():
    H,W = map(int, input().split())

    S = ["" for _ in range(H)]
    for i in range(H):
        S[i] = input()

    INF = float("inf")
    N = H*W
    dp = [[INF for _ in range(N)] for _ in range(N)]

    for i in range(H):
        for j in range(W):
            
            if j != W-1 and S[i][j] == "." and S[i][j+1] == ".":
                dp[(W*i)+j][(W*i)+j+1] = 1
                dp[(W*i)+j+1][(W*i)+j] = 1

            if i != H-1 and S[i][j] == "." and S[i+1][j] == ".":

                dp[(W*i)+j][(W*(i+1))+j] = 1
                dp[(W*(i+1))+j][(W*i)+j] = 1
        
            dp[(W*i)+j][(W*i)+j] = 0


    N = H*W
    for k in range(N):
        for i in range(N):
            for j in range(N):
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])

    ans = 0
    for i in range(N):
        for j in range(N):
            if dp[i][j] != INF:
                ans = max(ans, dp[i][j])
    
    print(ans)

if __name__ == "__main__":
    main()

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

typedef long long ll;
#define NUM 40001

int n,m;
int q;
vector<int> a(20,0);
vector<bool> table(NUM,false);

void setable(int d,int i){
    if(i>20){
        return;
    }else{
        table[d]=true;
        setable(d,i+1);
        setable(d+a[i],i+1);
    }
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    a.resize(n);
    for(int i=0;i<n;i++)cin >> a[i];
    setable(0,0);
    cin >> q;
    for(int i=0;i<q;i++){
        cin >> m;
        if(table[m])cout << "yes\n";
        else cout << "no\n";
    }
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;

int main() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  rep(i,m) cin >> b[i];
  int ans = 0;
  rep(i,n){
    vector<int> a(m);
    rep(i,m) cin >> a[i];
    int sum = 0;
    rep(i,m){
      sum += a[i]*b[i];
    }
    sum += c;
    if(sum>0) ++ans;
  }
  cout << ans << endl;
  return 0;
}

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


void findTrailingZeros(int n) 
{ 
	// Initialize result 
	int count = 0; 

	for (int i = 10; n / i >= 1; i *=(5)) 
		{
			count += n / i; 
			// c++;
		}

		if(n%2==0)
	cout<<count<<endl;
else
	cout<<0<<endl;
	
} 

int32_t main() 
{ 
	
		int n ; 
		cin>>n;
	findTrailingZeros(n); 
	
	
	return 0; 
} 


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <numeric>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

#define rep(i,n) for(int i = 0; i<n ; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)
#define REPSTR(i,s) for(int i=0; (s)[i]; i++)
#define REPITR(i,s) for(auto i=(s)begin(); i!=(s).end();i++)

#define RANGE(a,i,b) ((a)<=(i)&&(i)<=(b))

#define pb push_back
#define mp make_pair

#define ALL(a) (a).begin(), (a).end()

#define EXIST(s,x) ((s).find(x)!=(s).end())

#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))

#define DEBUG(x) cerr<<#x<<":"<<x<<endl
#define PRINTJOIN(x,n) rep(i,n){if(i)cout<<" ";cout<<x[i];}cout<<endl 

#define INF 1001001001
#define LLINF 1001001001001001001LL

typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef stringstream SS;

#define PQ priority_queue

#define FST first
#define SEC second

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//------------------HEAD---------------------

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true){
    int n;
    cin>>n;
    if(n==0)return 0;
    n=1000-n;
    int ans=n/500+n%500/100+n%100/50+n%50/10+n%10/5+n%5;
    cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3004
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

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

using ll = long long int;
using pll = pair<ll, ll>;

struct R
{
    string name;
    ll score;
    ll index;

    bool operator<(const R& r) const
    {
        if (this->name == r.name) { return this->score >= r.score; }
        return this->name < r.name;
    }
};


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

    vector<R> rs(n);

    rep(i, n)
    {
        cin >> rs[i].name >> rs[i].score;
        rs[i].index = i + 1;
    }

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

    rep(i, n)
    {
        cout << rs[i].index << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stack>
#include <array>
#include <queue>
#include <string>
#include <vector>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <new>
#include <map>
#define ESP (1e-13)
#define INF 2000000000
#define ll long long

using namespace std;

int main() {
	int N;
	cin >> N;
	int a;
	int j1=0,j2=0,j4=0;
	for (int i = 0;i < N;i++) {
		cin >> a;
		if (a % 4 == 0) j4++;
		if (a % 4 == 2) j2++;
		if (a % 2 == 1) j1++;
	}
	if (j1<=j4||(j1==j4+1&&j2==0)) {
		cout << "Yes" << endl;
		return 0;
	}
	else {
		cout << "No" << endl;
		return 0;
	}

}


Measured memory_bytes: 256
X, K, D = list(map(int,input().split()))

def calcu(x,k,D):
    if x == 0:
        if k%2 == 0:
            return 0
        else:
            return D

    a = int(x/D)
    if k <= a:
        x = x - k*D
        return x
    else:
        x1 = x- a*D
        x2 = x1 - D
        k = k - a
        if k%2 == 0:
            return x1
        else:
            return abs(x2)

        


if X >= 0:
    print(calcu(X,K,D))
else:
    print(calcu(-X,K,D))

Measured memory_bytes: 9152
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func Includethree(n int) bool {
	for {
		if n%10 == 3 {
			return true
		}
		n /= 10
		if n == 0 {
			return false
		}
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	for i := 1; i <= n; i++ {
		if i%3 == 0 || Includethree(i) {
			fmt.Printf(" %v", i)
		}
	}
	fmt.Println()
}



Measured memory_bytes: 1128
#include <bits/stdc++.h>
using namespace std;
#define maxn 200000
#define int long long
int n, a[maxn];

int read()
{
	int x = 0, k = 1;
	char c; c = getchar();
	while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * k; 
}

signed main()
{
	n = read();
	for(int i = 1; i <= n; i ++) a[i] = read();
	sort(a + 1, a + 1 + n);
	while(n && a[n] != a[n - 1]) n --;
	int t = a[n]; n -= 2;
	while(n && a[n] != a[n - 1]) n --;
	t *= a[n];
	if(!n) cout << 0 << endl;
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 1024
# coding: utf-8

def solve(X, Ls):
  c, s = 0, 0
  for L in Ls:
    s += L
    if s > X:
      break
    c += 1
  return c + 1


if __name__ == '__main__':
  _, X = map(int, input().split())
  print(solve(X, map(int, input().split())))

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
typedef long long int ll;
typedef vector<int> vi;

const int N = 2e5 + 10;
const int EMPTY = N-1;

int n, a[N], last[N], nxt[N], beg[N], follow[N], jump[N], njump[N];
ll k;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    forn(i,n) cin >> a[i+1]; a[0] = EMPTY;
    n++;

    beg[n] = EMPTY;
    dforsn(i,0,n) {
        if (last[a[i]]) beg[i] = beg[last[a[i]]+1];
        else beg[i] = a[i];

        last[a[i]] = i;
    }

    forn(i,n) if (!follow[a[i]]) follow[a[i]] = i+1;
    forn(i,n) jump[a[i]] = beg[follow[a[i]]];

    int start = EMPTY;
    auto e = k-1;
    while (e > 0) {
        if (e&1) start = jump[start];
        forn(i,n) njump[a[i]] = jump[jump[a[i]]];
        forn(i,n) jump[a[i]] = njump[a[i]];
        e /= 2;
    }

    vector<bool> in(N);
    vi ans; 
    forsn(i, follow[start], n) {
        if (in[a[i]]) {
            while (1) {
                auto x = ans.back();
                ans.pop_back();
                in[x] = 0;
                if (x == a[i]) break;
            }
        }
        else {
            ans.push_back(a[i]);
            in[a[i]] = 1;
        }
    }
    for (auto x : ans) cout << x << ' ';

    return 0;
}


Measured memory_bytes: 7412