akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N;
  cin>>N;
  
  vector<int> a(N+1);
  for(int i=1;i<=N;i++){
    cin>>a.at(i);
  }
  
  int b=1;
  int j=1;
  while(true){
    b=a.at(b);
    if(b==2){
      cout << j << endl;
      break;
    }
    if(j>=N){
      cout << -1 << endl;
      break;
    }
    j++;
  }
}


Measured memory_bytes: 640
class Main
{
	public static void main( String[] args )
	{
		java.util.Scanner sc = new java.util.Scanner( System.in );
		
		while( sc.hasNext() )
		{
			int a,b;
			
			a = sc.nextInt();
			b = sc.nextInt();
			
			int c = a+b;
			
			int d = 0;
			while( c != 0 ){
				d++;
				c = c/10;
			}
			
			System.out.println( d );
		}
	}
}

Measured memory_bytes: 26492
#include<iostream>
#include<string>
#include<stack>
using namespace std;
stack<char> p;
int main(){
	string s;
	cin>>s;
	int n=s.length();
	int count=0;
	p.push(s[0]);
	for(int i=1;i<n;i++){
		if(p.top()!=s[i]){
			p.pop();
			count++;
		} 
		else p.push(s[i]);
		if(p.empty() && i!=n-1){
			p.push(s[i+1]);
			i++;
		}		
	}
	cout<<count*2<<endl;
	return 0;
}


Measured memory_bytes: 512
n = int(input())
al = list(map(int,input().split()))

if n % 2 == 0:
    for a in list(reversed(al[1::2])) + al[0::2]:
        print(a)
else:
    for a in list(reversed(al[0::2])) + al[1::2]:
        print(a)

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

int main() {
  int a, b, c, k;
  std::cin >> a >> b >> c >> k;
  int ratio = 1 << k;

  std::cout << std::max({a, b, c}) * ratio + a + b + c - std::max({a, b, c}) << std::endl;
  return 0;
}


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

using namespace std;

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

int main(int argc, char* argv[]) {
  long long N, K;
  cin >> N >> K;

  vector<long long> a(N);
  long long maximum = 0;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    maximum = max(a[i], maximum);
  }

  if (maximum < K) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }

  long long g = a[0];
  for (int i = 1; i < N; ++i) {
    g = gcd(g, a[i]);
  }

  if (g <= K && K % g == 0) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  for(int i=n;i>0;i--){
    if(s.substr(n-i,i)==t.substr(0,i)){
      cout << 2*n-i << endl;
      return 0;
    }
  }
  cout << 2*n << endl;
  return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

#define int ll

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

  string s,t;
  cin>>s>>t;
  vector<map<char,int>>ms(s.size()+1);
  bool ok=true;
  ms[s.size()-1][s[s.size()-1]]=1;
  for(int i=s.size()-1;i>0;i--){
    for(auto it:ms[i])ms[i-1][it.first]=it.second+1;
    ms[i-1][s[i-1]]=1;
  }
  for(auto it:t)if(ms[0][it]==0)ok=false;
  if(!ok){
    cout<<-1<<endl;
    return 0;
  }
  int ans=0;
  int now=0;
  for(auto it:t){
    if(ms[now][it]>0){
      now+=ms[now][it];
    }
    else{
      ans++;
      now=0;
      now+=ms[now][it];
    }
  }

  cout<<ans*s.size()+now<<endl;
  return 0;
}


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

int dy[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
int dx[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
int x[100010], y[100010];

int main(void){
	int h, w, n; cin >> h >> w >> n;
	set<pair<int, int> > s;
	set<pair<int, int> > used;
	rep(i, n){
		int a, b; cin >> a >> b;
		a--; b--;
		y[i] = a; x[i] = b;
		s.insert(make_pair(a, b));//y,x
	}

	ll ans[10];
	rep(i, 10) ans[i] = 0;

	rep(i, n){
		rep(j, 9){
			//黒の周りから3x3の真ん中となりうるものをcy,cx
			int cy = y[i] + dy[j], cx = x[i] + dx[j];
			if(!(0 <= cy && cy < h && 0 <= cx && cx < w)) continue;
			if(used.count(make_pair(cy, cx)) == 1)continue;//すでに調べた
			int tmp = 0;
			rep(k, 9){//cy,cxを中心とした3x3を調べる
				int ny = cy + dy[k], nx = cx + dx[k];
				if(!(0 <= ny && ny < h && 0 <= nx && nx < w)) break;
				if(s.count(make_pair(ny, nx)) == 1)tmp++;
				if(k == 8){
					used.insert(make_pair(cy, cx));
					ans[tmp]++;
				}
			}
		}		
	}
	ll sum = 0;
	rep(i, 10){//1~9の合計
		sum += ans[i];
	}
	//0は全ての3x3から1~9の合計を引けばいい
	printf("%lld\n", ((ll)h - 2) * ((ll)w - 2) - sum);
	for (int i = 1; i <= 9; ++i){
		printf("%lld\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 47872
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append((v, w))
    G[v].append((u, w))

C = [-1 for _ in range(N)]


def dfs(pos, color):
    C[pos] = color
    for e in G[pos]:
        if C[e[0]] != -1:
            continue
        # odd
        if e[1] & 1:
            c = 1 - color
            dfs(e[0], c)
        # even
        else:
            c = color
            dfs(e[0], c)


dfs(0, 0)
for i in range(N):
    print(C[i])


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

public class Main {
  private static int solve(int n, int k, int[] as) {
    int[] counts = new int[n + 1];
    for (int a : as) {
      counts[a]++;
    }
    
    Arrays.sort(counts);
    int sum = 0;
    for (int i = 0; i <= n - k; i++) {
      sum += counts[i];
    }
    return sum;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int k = reader.nextInt();
    int[] as = reader.nextInt(n);
    out.println(solve(n, k, as));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 47304
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if (s.front() == s.back()) {
		if (s.size() % 2 == 0) {
			cout << "First" << endl;
		}
		else {
			cout << "Second" << endl;
		}
	}
	else {
		if (s.size() % 2 == 1) {
			cout << "First" << endl;
		}
		else {
			cout << "Second" << endl;
		}
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string X;
  bool G=false;
    bool W=false;
    bool Y=false;
    bool P=false;

  cin >> N;
for(int i=0; i < N; i++){
	cin >> X ;
	if (X=="G") G = true ;
	if (X=="W") W = true ;
	if (X=="Y") Y = true ;
	if (X=="P") P = true ;
}
if(Y==true)
	cout<< "Four" <<endl;
else cout<< "Three" <<endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            int[] cnt = new int[256];
            for (int i = 0; i < s.length(); ++i) ++cnt[s.charAt(i)];
            if (cnt['E'] == 0 ^ cnt['W'] == 0) {
                out.println("No");
                return;
            }
            if (cnt['N'] == 0 ^ cnt['S'] == 0) {
                out.println("No");
                return;
            }
            out.println("Yes");
        }

    }

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

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

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

    }
}



Measured memory_bytes: 8276
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define MOD 1000000007
//#define MOD 998244353
#define EPS (1 >> 30)
//#define INF (1 << 30)
#define INF (1LL << 60)
#define ff first
#define se second
//#define int long long
const int dx[]={0,-1,0,1};
const int dy[]={1,0,-1,0};

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

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

    double a,b,x;
    cin>>a>>b>>x;
    double h=x/(a*a);
    double y=h/b;
    if(2*h>=b){
        cout<< atan((b-h)/(a/2))*180/3.14159265359<<endl;
    }
    else{
        cout<< atan((b*b)/(2*h*a))*180/3.14159265359<<endl;
    }
    
}

Measured memory_bytes: 256
import numpy as np
N=int(input())
a=np.array(list(map(int,input().split())))

def calc(b):
    ret=0
    for i in a:
        ret+=abs(i-b)
    return ret

for i in range(N):
    a[i]-=(i+1)
a=np.sort(a)
median=int(np.median(a))

ans1=calc(median)
ans2=calc(median+1)
print(min(ans1,ans2))

Measured memory_bytes: 34208
n, d = map(int, input().split())
l = list("")
for i in range(n):
    x = list(map(int, input().split()))
    l.append(x)
c = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        a = 0
        for k in range(d):
            a += (l[i][k] - l[j][k]) ** 2
        a = a ** 0.5
        if int(a) == a:
            c += 1
print(c)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef long long ll;
ll mod=ll(1e9)+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k;
  cin>>k;
  vector<ll> a;
  for(int i=1;i<10;i++)a.push_back(i);
  while(1){
      if(k<=a.size()){
          cout<<a[k-1]<<endl;
          return 0;
      }
      k-=a.size();
      vector<ll> old;
      swap(old,a);
      for(ll x:old){
          for(int i=-1;i<2;i++){
              int d=x%10+i;
              if(d<0|| d>9) continue;
              ll nx=x*10+d;
              a.push_back(nx);
          }
      }
  }
  return 0;
}


Measured memory_bytes: 1712
H,W = map(int,input().split())
if H == 1 or W == 1:
    print(1)
    exit()

if H % 2 == 0:
    h = int(H/2)
    ans = h * W
    print(ans)
    exit()
else:
    h = int(H/2)+1
if W % 2 == 0:
    w = int(W/2)
else:
    w = int(W/2)+1

# print(h,w)
ans = h*w + (W-w)*(h-1)

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

int main(){
	int a[4];
	int b[4];
	int i,j;
	while(scanf("%d %d %d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])!=EOF){
		int hit=0,blow=0;
		for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			if(a[i]==b[j]){
				if(i==j){
					hit++;
				}else{
					blow++;
				}
			}
		}
		}
		printf("%d %d\n",hit,blow);
	}
	
	return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
// #ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
       *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
// #else
// sim dor(const c&) { ris; }
// #endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int maxn=2e5+5;
vector<int> adj[maxn];
int vis[maxn],cur;

void dfs(int u){
    cur++;
  	vis[u]=1;
    for(int v:adj[u]){
        if(vis[v]){
            continue;
        }
        dfs(v);
    }
}

void solve(){
    int n,m;
    cin>>n>>m;
    memset(vis,0,maxn);
    for(int i=0;i<n;i++){
        adj[i].resize(0);
    }
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        --u,--v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int ans=1;
    for(int i=0;i<n;i++){
        cur=0;
        if(vis[i]){
            continue;
        }
        dfs(i);
        ans=max(ans,cur);
    }
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 21660
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
  for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
  for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
  return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
  os<<"{ ";for(auto m:M)os<<"("<<m.first<<":"<<m.second<<")";
  return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
//For multiset use less_equal operator but it does support erase operations for multiset
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) (v).begin(),(v).end()
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mp make_pair


const int mod = 1e9+7;
const ll INF = 1e17;

inline int add(int a,int b){a+=b;if(a>=mod)a-=mod; return a;} 
inline int sub(int a,int b){a-=b;if(a<0) a += mod; return a;}
inline int mul(int a, int b){ return a*1ll*b%mod;}
inline int power(int x, ll y){
  int res = 1;
  while(y){
    if(y&1) res = mul(res , x);
    x = mul(x,x);
    y >>= 1;
  }
  return res;
}

int main(){
  fio; cout<<fixed<<setprecision(25);	
  ll x, k ,d;
  cin >> x >> k >> d;

  if(x%d == 0){
    if(abs(x)/d <= k){
      if(k%2 == ( abs(x)/d)%2 ){
        cout << 0 << endl;
      }
      else{
        cout << d << endl;
      }
    }
    else{
      cout << abs(x) - k*d << endl; 
    }
    return 0;
  }
  ll mn = INF; 
  if(k <= INF/d)
  mn = min(mn, abs(x+k*d));
  if(k <= INF/d)
  mn = min(mn, abs(x-k*d));
  ll z = (x%d+d)%d;
  ll req = abs(x-z)/d;
  if(k >= req && req%2 == k%2) mn = min(mn, z);
  z -= d;
  req = abs(x-z)/d;
  if(k >= req && req%2 == k%2) mn = min(mn, abs(z));
  cout << mn << endl;
  return 0;
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,d;
	cin>>n>>d;
	int c = 0;

	while(n--){
		long long x,y;
		cin>>x>>y;
		double res = sqrt((pow(x,2)+pow(y,2)));
		if(res <=d){
			c++;
		}
	}
	cout<<c;
}

Measured memory_bytes: 3660
N, M, C = [int(i) for i in input().split()]
B = list(map(int, input().split()))
A = []
for i in range(N):
    A.append(list(map(int, input().split())))
ans = 0
for i in range(N):
    a = 0
    for j in range(M):
        a += A[i][j]*B[j]
    a += C
    if a > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
const int MOD = 1000000007;


template <typename T>
void __dump__(std::ostream &os, const T &first) {
    os << first;
}
template <typename First, typename... Rest>
void __dump__(std::ostream &os, const First &first, const Rest &... rest) {
    os << first << ", ";
    __dump__(os, rest...);
}
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __dump__(os, __VA_ARGS__);                        \
        std::cerr << os.str() << std::endl;               \
    } while (0)

const ll INF = 1e18;

ll solve(ll a, ll b) {
    ll res = INF;
    if (a >= 3) {
        int a1 = a / 3, a2 = (a + 2) / 3;
        res = min(res, (a2 - a1) * b);
    }
    for (int i = 1; i <= a - 1; ++i) {
        int h1 = b / 2;
        int h2 = b - h1;
        int w1 = i;
        int w2 = a - w1;
        int s1 = h1 * w1;
        int s2 = h2 * w1;
        int s3 = b * w2;
        int ss[] = { s1, s2, s3 };
        sort(all(ss));
        int cand = ss[2] - ss[0];
        res = min(res, cand);
    }
    return res;
}

signed main() {
    ll a, b;
    while (cin >> a >> b) {
        cout << min(solve(a, b), solve(b, a)) << endl;
    }
}


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

void solve(long long N, std::vector<long long> X){
    vector<ll> x = X;
    sort(x.begin(), x.end());
    for(ll i = 0; i < N; ++i){
        if(X[i] < x[N/2]) cout << x[N/2] << endl;
        else cout << x[N/2-1] << endl;
    }
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
    }
    solve(N, std::move(X));
    return 0;
}


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

using ll=long long;

int main() {
  double N,X,T; cin >>N >>X >>T;
  cout <<int(ceil(N/X)*T) <<endl;
  return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
std::vector<int> find_all(const std::string str, const std::string subStr) {
  std::vector<int> result;

  int subStrSize = subStr.size();
  int pos = str.find(subStr);

  while (pos != std::string::npos) {
    result.push_back(pos);
    pos = str.find(subStr, pos + subStrSize);
  }

  return result;
}
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  string s;
  cin >> n >> s;
  cout << find_all(s, "ABC").size() << endl;
  return 0;
}


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

int main() {
	int n, q, query, t, x, s;
	cin >> n >> q;
	vector<list<int>> a(n);
	for (int i = 0; i < q; i++) {
		cin >> query;
		if (query == 0) {
			cin >> t >> x;
			a[t].push_back(x);
		}
		else if (query == 1) {
			cin >> t;
			for (list<int>::iterator i = a[t].begin(); i != prev(a[t].end()); i++) cout << *i << ' ';
			if (!a[t].empty()) cout << *prev(a[t].end());
			cout << endl;
		}
		else {
			cin >> s >> t;
			a[t].splice(a[t].end(), a[s]);
		}
	}
}


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

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

const int MAX_N = 100000;
int main(){
    iostream_init();
    LL N;
    cin >> N;
    LL sum[MAX_N] = {};
    LL first = -1;
    for(LL i = 1; i <= N; i++) {
        sum[i] = sum[i-1] + i;
        if(sum[i] >= N) {
            first = i;
            break;
        }
    }
    int idx = first;
    while(N > 0) {
        while(sum[idx-1] >= N) {
            idx--;
        }
        cout << idx << endl;
        N -= idx;
        idx--;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
using namespace std;

#define L 4194304
bool HA[L];
int T[256] = {0};

inline int get( unsigned char c ) {
    return T[c];
}

int main() {
    int n, sum, t, c;
    T['A'] = 1, T['C'] = 2, T['G'] = 3, T['T'] = 4;
    while ( scanf("%d", &n) != EOF ) {
        memset(HA,false,L);
        while ( getchar() != '\n' );
        for ( register int i = 0; i++ < n; ) {
            sum = 0;
            t = 1;
            bool flag = ( c = getchar() ) == 'i';
            while ( ( c = getchar() ) != ' ' );
            while ( ( c = T[getchar()] ) != 0 ) {
                sum += c * t;
                t *= 4;
            }
            if ( flag ) {
                HA[sum] = true;
            } else {
                puts( HA[sum] ? "yes" : "no" );
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4832
#include<bits/stdc++.h>
using namespace std;
int ans=0;

int main()
{
  int n;
  cin>>n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  int active=0;
  for(int i=0;i<n;i++){
    if(active>=h[i]){
      active=h[i];
    }
    else {
      ans+=h[i]-active;
      active=h[i];
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
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;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n,m,nf,ne,s,d;cin>>n>>m>>nf>>ne>>s>>d,n|m|nf|ne|s|d;){ // 頂点数,何分保つか,冷凍施設数,辺数,首都の番号,病院の番号
		vi fs(nf);
		rep(i,nf) cin>>fs[i];
		vvi dp(n,vi(n,INFTY));
		rep(i,n) dp[i][i]=0;
		rep(i,ne){
			int a,b,t; cin>>a>>b>>t;
			dp[a][b]=dp[b][a]=t;
		}
		
		rep(k,n) rep(i,n) rep(j,n)
			dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
		
		vvi dp2(n,vi(n,INFTY));
		rep(i,n) dp2[i][i]=0;
		dp2[s][d]=dp[s][d]<=m?dp[s][d]:INFTY;
		rep(i,nf){
			dp2[s][fs[i]]=dp[s][fs[i]]<=m?dp[s][fs[i]]:INFTY;
			dp2[fs[i]][d]=dp[fs[i]][d]<=m?dp[fs[i]][d]:INFTY;
			rep(j,nf)
				dp2[fs[i]][fs[j]]=dp[fs[i]][fs[j]]<=m?dp[fs[i]][fs[j]]:INFTY;
		}
		
		rep(k,n) rep(i,n) rep(j,n)
			dp2[i][j]=min(dp2[i][j],dp2[i][k]+dp2[k][j]);
		
		if(dp2[s][d]==INFTY)
			cout<<"Help!"<<endl;
		else
			cout<<dp2[s][d]+max(dp2[s][d]-m,0)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1304
p=[]
m=[]
ans=0
p.append(int(input()))
p.append(int(input()))
p.append(int(input()))
p.append(int(input()))
p.append(int(input()))

for i in p:
    if i%10==0:
        ans += i
    else:
        ans += (1+i//10)*10


for i in p:
    if i%10 != 0:
        m.append(i%10)

if len(m) >0:
    print(ans - (10-min(m)))
else:
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k;
	vector<int> a = { 100,101,102,103,104,105 };
	cin >> n;
	vector<bool> dp(n + 1, false);
	dp[0] = true;
	for (i = 0; i < n; i++) {
		if (dp[i]) {
			for (auto p : a) {
				if (i + p <= n) dp[i + p] = true;
			}
		}
	}
	if (dp[n]) cout << "1\n";
	else cout << "0\n";
		
	return 0;
}


Measured memory_bytes: 256
n,d = map(int,input().split())
x = [[] for _ in range(n)]
for i in range(n):
	x[i] = list(map(int,input().split()))
#8000
ansk = 0
l = set([i**2 for i in range(300)])
for i in range(n):
	for j in range(i+1, n):
		ans = 0
		for k in range(d):
			ans += (x[i][k]-x[j][k])**2
		if ans in l:
			ansk += 1
print(ansk)

Measured memory_bytes: 3064
n, m = map(int, input().split()) 
a = list(map(int, input().split()))
b = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-1] * (n + 1)
dp[n] = 0

for i in range(n, -1, -1):
    for j in range(m):
        x = b[a[j]]
        if dp[i] != -1 and i - x >= 0:
            dp[i - x] = max(dp[i - x], 10 * dp[i] + a[j])
            
print(dp[0])

Measured memory_bytes: 20560
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

ll a[3000];
ll dp[3000][3000];

ll dfs(int left, int right, int turn) {
    if (dp[left][right] != -1) {
        return dp[left][right];
    }
    if (left == right) {
        return dp[left][right] = turn == 0 ? a[left] : -a[left];
    }
    if (turn == 0) {
        ll ret = -INF;
        chmax(ret, dfs(left + 1, right, 1) + a[left]);
        chmax(ret, dfs(left, right - 1, 1) + a[right]);
        return dp[left][right] = ret;
    } else {
        ll ret = INF;
        chmin(ret, dfs(left + 1, right, 0) - a[left]);
        chmin(ret, dfs(left, right - 1, 0) - a[right]);
        return dp[left][right] = ret;
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < 3000; ++i) {
        for (int j = 0; j < 3000; ++j) {
            dp[i][j] = -1;
        }
    }
    cout << dfs(0, n - 1, 0) << "\n";
    return 0;
}

Measured memory_bytes: 70656
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=mp()
l=[]
for i in range(m):
    l.append(lmp())
ans=[0]*m    
ans[m-1]=n*(n-1)//2
uf=UnionFind(n+1)
for i in range(m-1):
    if not uf.same(l[m-1-i][0],l[m-1-i][1]):
        ans[m-2-i]=ans[m-i-1]-uf.size(l[m-1-i][0])*uf.size(l[m-1-i][1])
        uf.union(l[m-1-i][0],l[m-1-i][1])
    else:
        ans[m-2-i]=ans[m-i-1]
for a in ans:
    print(a)    


Measured memory_bytes: 98400
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    ll L,R;
    cin >> L >> R;
    if(R-L>=2019)
        cout << 0 << endl;
    else {
        ll memo=2018;
        for(ll i=L;i<R;i++){
            for(ll j=i+1;j<=R;j++)
                memo=min(memo,(i*j)%2019);

        }
        cout << memo << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Set<Integer> num = new HashSet<>();
        for(int i = 0; i < N; i++) {
            int di = sc.nextInt();
            num.add(di);
        }
        System.out.println(num.size());
    }
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

void _main() {
  int N;
  cin >> N;

  int odd   = 0;
  rep(i, 0, N) {
    int tmp;
    cin >> tmp;
    if (0 != tmp%2) odd++;
  }

  if (0 == odd%2)
    cout << "YES" << "\n";
  else
    cout << "NO" << "\n";
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int A[100001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	int kotae = 0;
	rep(i, N) {
		int a = getint();
		if (a <= 100000) A[a]++;
		else kotae++;
	}
	rep1(i, 100000) {
		if (A[i] >= i) kotae += A[i] - i;
		else kotae += A[i];
	}
	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<tuple>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};

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

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%MOD;
        a=a*a%MOD;
        x>>=1;
    }
    return res;
}
string s;

int main(){
    int n;cin>>n;
    vector<int> p(n),q(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    for(int i=0;i<n;i++){
        cin>>q[i];
    }
    vector<int> n1(n),n2(n);
    for(int i=0;i<n;i++){
        n1[i]=n2[i]=i+1;
    }
    int a=0;
    do{
        bool flag1=true;
        for(int i=0;i<n;i++){
            if(p[i]!=n1[i]){
                flag1=false;
                break;
            }
        }
        if(flag1) break;
        a++;
    }while(next_permutation(n1.begin(),n1.end()));
    int b=0;
    do{
        bool flag2=true;
        for(int i=0;i<n;i++){
            if(q[i]!=n2[i]){
                flag2=false;
                break;
            }
        }
        if(flag2) break;
        b++;
    }while(next_permutation(n2.begin(),n2.end()));
    cout<<abs(a-b)<<endl;
    return 0;
}

Measured memory_bytes: 256
import kotlin.math.min


fun solve(N: Long, A: Long, B: Long) {
    val rep = N / (A + B)
    val sur = N % (A + B)
    println(rep * A + min(A, sur))
}

fun main() {
//    val S = readLine()!!
//    val N = readLine()!!.toInt()
    val (N, A, B) = readLine()!!.split(" ").map { it.toLong() }
//    val A = readLine()!!.split(" ").map { it.toInt() }
    solve(N, A, B)
}

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

int main(){
  int a, b, t;
  cin >> a >> b >> t;
  int time = 0;
  int bis = 0;
  
  while(time <= t){
    bis += b;
    time += a;
  }
  
  bis -= b;
  cout << bis << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  int a=0,w=0,t=0,r=0;
  REP(i,n) {
    string s;
    cin>>s;
    switch (s[0]) {
      case 'A': ++a;break;
      case 'W': ++w;break;
      case 'T': ++t;break;
      case 'R': ++r;break;
    }
  }
  cout<<"AC x "<<a<<endl;
  cout<<"WA x "<<w<<endl;
  cout<<"TLE x "<<t<<endl;
  cout<<"RE x "<<r<<endl;
  return 0;
}


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

int main() {
	string S;
  	string T;
  	int count = 0;
	cin >> S >> T;
	rep(i,S.length()){
		if(S.at(i) == T.at(i)){
          count++;
        }
	}
  	cout << count << endl;
}


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

int main() {
  int N,T;
  cin >> N >> T;
  vector<pair<int,int>> vec(N);
  for(int i = 0;i < N;i++) {
    int A,B;
    cin >> A >> B;
    vec.at(i) = make_pair(B,A);
  }
  sort(vec.begin(),vec.end());
  int answer = 10000;
  bool A = true;
  for(int i = 0;i < N;i++) {
    if(vec[0].first > T) {
      A = false;
      break;
    }
    else if(vec[i].first > T) {
      break;
    }
    else {
      if(vec[i].second < answer) {
        answer = vec[i].second;
      }
    }
  }
  if(A == true) {
    cout << answer << endl;
  }
  else {
    cout << "TLE" << endl;
  }
}

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

int main(){
  string s,t;
  cin >> s >> t;
  int n = sz(s), m = sz(t);
  vector<vector<int>> dic(26);
  rep(i,n) dic[s[i]-'a'].push_back(i);
  rep(i,n) dic[s[i]-'a'].push_back(i+n);
  ll ans = 0;
  int p = 0;
  rep(i,m){
    int c = t[i]-'a';
    if(dic[c].size()==0){
      puts("-1");
      return 0;
    }
    p = *lower_bound(dic[c].begin(),dic[c].end(),p)+1;
    if(p>=n){
      p -= n;
      ans += n;
    }
  }
  ans += p;
  cout << ans << endl;
}


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

int main(){
  while(1){
    int h, w; cin >> h >> w;
    if(h == 0 && w == 0) break;
    rep(i,h){
      rep(j,w){
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}


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

int N;
int A, B, C;
int l[8];

int dfs(int k, int a, int b, int c) {
    if (k == N) {
        if (a == 0 || b == 0 || c == 0)
            return 1000000000;
        return abs(A - a) + abs(B - b) + abs(C - c);
    }
    int res = 1000000000;
    res = min(res, dfs(k + 1, a + l[k], b, c) + (a > 0 ? 10 : 0));
    res = min(res, dfs(k + 1, a, b + l[k], c) + (b > 0 ? 10 : 0));
    res = min(res, dfs(k + 1, a, b, c + l[k]) + (c > 0 ? 10 : 0));
    res = min(res, dfs(k + 1, a, b, c));
    return res;
}

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

    cout << dfs(0, 0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#define onlycc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <iostream>
#include <algorithm>
#include <string>
#define MOD 1000000007
using namespace std;

typedef long long ll;

ll s, dp[2001];

ll dist(ll n)
{
    if(dp[n] != 0) return dp[n];
    if(n == 0) return dp[n] = 1;

    int i;
    ll cnt = 0;
    for(i = 3; n-i >= 0; i++)
        cnt = (cnt + dist(n-i))%MOD;
    return dp[n] = cnt;
}

int main()
{
    onlycc;
    cin >> s;
    cout << dist(s);

    return 0;
}


Measured memory_bytes: 3672
import scala.io.StdIn

object Main{
  def main(args: Array[String]) = {
    def gcd(a: Int,  b: Int): Int = if (b == 0) a else gcd(b,  a % b)
    val (a :: b :: _) = StdIn.readLine().split(" ").map(_.toInt).toList
    println(gcd(a,  b))
  }
}

Measured memory_bytes: 43552
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
 
//Compiler version g++ 6.3.0
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(s.length()<=n){
      cout << s << "\n";
    } else {
      cout << s.substr(0,n) << "...\n";
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;

int main(void){
    int n,k;
    cin>>n>>k;
    int a=1;//2^a<=kとなるようにする
    //はじめに1が出たときにa回表が出ればk以上になる
    while((1<<a)<k) a++;
    int ans=0;//1が出た時の確立を単位として数える
    double q=n*(1<<a);//1が出て勝つ確率の逆数
    int temp=1;//初めにでた目
    int b=0;//a+bが一定になるようにする
    //a回で初めてk以上になるように
    while(temp<=n){
        if((temp<<(a-1))>=k){
            a--;
            b++;
        }
        //cout<<temp<<" "<<(1<<b)<<endl;
        ans+=(1<<b);
        temp++;
    }
    //cout<<ans<<" "<<q<<endl;
    double p=double(ans/q);
    //cout<<p<<endl;
    printf("%.15f\n",p);
    return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,K;cin>>A>>B>>C>>K;
  if(A>=B&&A>=C){
    for(int i=0;i<K;i++)A*=2;
  }
  else if(B>=A&&B>=C){
    for(int i=0;i<K;i++)B*=2;
  }
  else{
    for(int i=0;i<K;i++)C*=2;
  }
  
  cout<<A+B+C<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main(){
	string n;
	while(getline(cin,n),n!="."){
		stack<char>x;
		bool ans=true;
		for(int i=0;i<n.size();i++){
			char now;
			if(n[i]=='(')x.push(n[i]);
			if(n[i]=='[')x.push(n[i]);
		
			if(n[i]==')'){
				if(x.empty()){
					ans=false;
					break;
				}
			now=x.top();
			x.pop();
			if(now!='(')ans=false;
			}
			if(n[i]==']'){
				if(x.empty()){
					ans=false;
					break;
				}
				now=x.top();
				x.pop();
				if(now!='[')ans=false;
			}
		}
		
	if(x.empty()==false)ans=false;
	if(ans)cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1176
N = int(input())
array = list(map(int, input().strip().split()))
array.sort()
ans = 0
a = [True] * (10**6 + 1)
i = 0
before = 0
for i in array:
    if a[i] == True:
        j = 2*i
        if i == before:
            a[i] = False
        while j <= array[N-1]:
            a[j] = False
            j += i
        before = i
for i in array:
    if a[i] == True:
        ans += 1
print(ans)

Measured memory_bytes: 33096
#include <iostream>
#include <vector>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main() {
  int n;
  cin >> n;
  lli dp[100005][3] = {};
  lli val[100005][3] = {};
  rep(i, n) rep(j, 3) cin >> val[i][j];
  rep(i, n) rep(j, 3) {
    rep(k, 3) {
      if (k == j)
        continue;
      dp[i + 1][j] = max(dp[i][k] + val[i][j], dp[i + 1][j]);
    }
  }
  cout << max({dp[n][0], dp[n][1], dp[n][2]});
}


Measured memory_bytes: 4992
# 
from collections import deque
n,q = map(int,input().split())
G = [[] for _ in range(n)]
ans = [0]*n
for i in range(n-1):
    a,b = map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

for i in range(q):
    p,x = map(int,input().split())
    ans[p-1]+=x

q = deque([0])
visited=[False]*n

while q:
    v=q.pop()
    visited[v]=True
    for e in G[v]:
        if visited[e]:
            continue
        ans[e]+=ans[v]
        q.append(e)
print(*ans)


Measured memory_bytes: 56056