akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int n;
string s;
int tree[2000005];
void build(int i,int l,int r)
{
    if(l==r)
    {
        tree[i]=(1ll<<(s[l-1]-'a'));
        return;
    }
    int mid=(l+r)/2;
    build(i*2,l,mid);
    build(i*2+1,mid+1,r);
    tree[i]=tree[i*2]|tree[i*2+1];
}
void update(int i,int l,int r,int l1,int r1,int val)
{
    if(l1>r1 || l>r1 || l1>r)
        return;
    if(l1<=l && r<=r1)
    {
        tree[i]=(1ll<<val);
        return;
    }
    int mid=(l+r)/2;
    update(i*2,l,mid,l1,r1,val);
    update(i*2+1,mid+1,r,l1,r1,val);
    tree[i]=tree[i*2]|tree[i*2+1];
}
int query(int i,int l,int r,int l1,int r1)
{
    if(l1>r1 || l>r1 || l1>r)
        return 0;
    if(l1<=l && r<=r1)
        return tree[i];
    int mid=(l+r)/2;
    return query(i*2,l,mid,l1,r1)|query(i*2+1,mid+1,r,l1,r1);
}
int32_t main() 
{
    IOS;
    cin>>n>>s;
    build(1,1,n);
    int q;cin>>q;
    while(q--)
    {
        int type;
        cin>>type;
        if(type==2)
        {
            int a,b;
            cin>>a>>b;
            print(__builtin_popcount(query(1,1,n,a,b)));
        }
        else
        {
            int pos;char type;
            cin>>pos>>type;
            update(1,1,n,pos,pos,type-'a');
        }
    }
}   


Measured memory_bytes: 11944
#include <iostream>
using namespace std;
int main(void){
  int W,H,x,y,r;
  cin>>W>>H>>x>>y>>r;
 
  if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
	  cout<<"Yes\n";
  }else{
	  cout<<"No\n";
  }
}

Measured memory_bytes: 1124
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

int main(){
    int n,k;
    std::cin>>n>>k;
    std::vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        std::cin>>h[i];
    }
    std::vector<long long> cost(n,std::numeric_limits<long long>::max());
    cost[0]=0;
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j <= k; ++j) {
            if(i+j>=n)break;
            cost[i+j]=std::min(cost[i]+std::abs(h[i]-h[i+j]),cost[i+j]);
        }
    }
    std::cout<<cost[n-1]<<std::endl;
    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>

int main(){
  int n,q,i,j,count=0;

  scanf("%d",&n);
  int S[n];
  for(i=0 ; i<n ; i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  int T[q];
  for(j=0 ; j<q ; j++){
    scanf("%d",&T[j]);
  }

  for(i=0 ; i<q ; i++){
    for(j=0 ; j<n ; j++){
if(S[j] == T[i]){
  count++;
  break;
}
}
}

printf("%d",count);
printf("\n");

return 0;
}



Measured memory_bytes: 2104
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
struct S{
	int p,q;
	S(int p,int q):p(p),q(q){
	}
	bool operator<(const S& a)const{
		return p>a.p;
	}
};
int main(){
	int i,j;
	int n,m,l;;
	scanf("%d%d%d",&n,&m,&l);
	vector<pair<int,int> > a[3000];
	for(i=0;i<m;++i){
		int p,q,r;
		scanf("%d%d%d",&p,&q,&r);
		--p;
		--q;
		a[p].push_back(make_pair(q,r));
		a[q].push_back(make_pair(p,r));
	}
	int b[3000];
	memset(b,0x7f,sizeof(b));
	priority_queue<S> c;
	for(i=0;i<l;++i){
		int p;
		scanf("%d",&p);
		--p;
		b[p]=0;
		c.push(S(0,p));
	}
	while(!c.empty()){
		S p=c.top();
		c.pop();
		for(i=0;i<(int)a[p.q].size();++i){
			if(b[a[p.q][i].first]<=p.p+a[p.q][i].second)
				continue;
			b[a[p.q][i].first]=p.p+a[p.q][i].second;
			c.push(S(p.p+a[p.q][i].second,a[p.q][i].first));
		}
	}
	int mx=0;
	for(i=0;i<n;++i)
		for(j=0;j<(int)a[i].size();++j)
			mx=max(mx,max(b[i],b[a[i][j].first])+(a[i][j].second-abs(b[i]-b[a[i][j].first])+1)/2);
	printf("%d\n",mx);
	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p.at(i);
    sort(p.begin(), p.end());
    int ans = 0;
    rep(i,k) ans += p.at(i);
    cout << ans << endl; 
    return 0;
}

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

int main()
{

    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char>(w));
    int ans = 0;

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> c[i][j];
        }
    }

    for (int hbit = 0; hbit < (1 << h); hbit++)
    {
        vector<vector<char>> dst1(h, vector<char>(w));
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                dst1[i][j] = c[i][j];
            }
        }
        for (int i = 0; i < h; i++)
        {
            if (hbit & (1 << i))
            {
                for (int j = 0; j < w; j++)
                {
                    if (c[i][j] == '#')
                    {
                        dst1[i][j] = '.';
                    }
                }
            }
        }
        for (int wbit = 0; wbit < (1 << w); wbit++)
        {
            vector<vector<char>> dst2(h, vector<char>(w));
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    dst2[i][j] = dst1[i][j];
                }
            }
            for (int j = 0; j < w; j++)
            {
                if (wbit & (1 << j))
                {
                    for (int i = 0; i < h; i++)
                    {
                        if (c[i][j] == '#')
                        {
                            dst2[i][j] = '.';
                        }
                    }
                }
            }
            int sumk = 0;
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    if (dst2[i][j] == '#')
                    {
                        sumk++;
                    }
                }
            }
            if (sumk == k)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int n, ans[26];
	rep(i, 26)
		ans[i] = 100000;
	
	cin >> n;
	
	rep(i, n){
		int count[26] = {};
		string s;
		cin >> s;
		rep(j, s.length())
			rep(c, 26)
				if(s[j] == 'a' + c)
					count[c]++;	
		rep(k, 26)
			ans[k] = min(ans[k], count[k]);
	}
	
	rep(i, 26)
		rep(j, ans[i])
			cout << char('a' + i);
		
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int a[N];
  for(int i=0;i<N;++i) cin>>a[i];
  vector<int> arr1, arr2;
  map<int, int> amap, bmap;
  for(int i=0;i<N;++i) {
    if(i%2==0) {
      if(amap[a[i]]==0) arr1.push_back(a[i]);
      amap[a[i]]++;
    }
    else {
      if(bmap[a[i]]==0) arr2.push_back(a[i]);
      bmap[a[i]]++;
    }
  }
  vector<pair<int, int> > arr11, arr22;
  for(int i=0;i<arr1.size();++i) arr11.push_back(mp(amap[arr1[i]], arr1[i]));
  for(int i=0;i<arr2.size();++i) arr22.push_back(mp(bmap[arr2[i]], arr2[i]));
  sort(arr11.begin(), arr11.end(), greater<pair<int, int> >());
  sort(arr22.begin(), arr22.end(), greater<pair<int, int> >());
  int ans;
  if(arr11[0].se!=arr22[0].se) {
    ans = N-arr11[0].fi-arr22[0].fi;
  }
  else if(arr11.size()>1 && arr22.size()>1) {
    ans = N-arr11[0].fi-arr22[1].fi;
    ans = min(ans, N-arr11[1].fi-arr22[0].fi);
  }
  else if(arr11.size()==1 && arr22.size()>1) {
    ans = N-arr11[0].fi-arr22[1].fi;
    ans = min(ans, N-arr22[0].fi);
  }
  else if(arr11.size()>1 && arr22.size()==1) {
    ans = N-arr11[1].fi-arr22[0].fi;
    ans = min(ans, N-arr11[0].fi);
  }
  else {
    ans = N-arr11[0].fi;
    ans = min(ans, N-arr22[0].fi);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 9668
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;

signed main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll a,b; cin >> a >> b;
    cout << a*b-(a+b-1) << endl;
}


Measured memory_bytes: 256
let n = Scanf.scanf " %d" (+) 0
let ss = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let sum = Array.fold_left (+) 0 ss
let _ = Printf.printf "%d\n" @@ if sum mod 10 <> 0 then sum else sum - Array.fold_left (fun m s -> if s mod 10 <> 0 then min m s else m) sum ss

Measured memory_bytes: 384
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

void main(){
    int n, q, c, x, y;
    readVars(n, q);

    int[] a = new int[](n);
    a[] = int.max;

    auto sg = new SegTree!(int)(a);

    //sg.print;

    foreach(qi ; 0 .. q){
        readVars(c, x, y);

        if(c == 0){
            sg.update(x, y);
        } else {
            writeln(sg.find(x, y + 1, 0, 0, 2^^sg.depth));
        }

        //sg.print;
    }
}

class SegTree(T){
private:
    T[] data;
    int N;

public:
    int depth;

    this(T[] a){
        N = a.length.to!int;

        while(2^^depth < N){
            depth++;
        }

        data = new int[](2^^(depth + 1) - 1);

        data[] = int.max;
        data[2^^depth - 1 .. 2^^depth - 1 + N] = a[];

        foreach_reverse(i ; 0 .. 2^^depth - 1){
            data[i] = min(data[2*i + 1], data[2*i + 2]);
        }
    }

    void update(int i, T x){
        i += 2^^depth - 1;
        data[i] = x;

        while(i > 0){
            i = (i - 1) / 2;
            data[i] = min(data[2*i + 1], data[2*i + 2]);
        }
    }

    T find(int s, int t, int k, int l, int r){
        if (r <= s || t <= l) {
            return int.max;
        }

        if (s <= l && r <= t) {
            return data[k];
        }

        auto vl = find(s, t, 2*k + 1, l, (l + r) / 2);
        auto vr = find(s, t, 2*k + 2, (l + r) / 2, r);

        return min(vl, vr);
    }

    void print(){
        stderr.writefln("%(%s %)", data);
    }
}

class FenwickTree(T){
private:
    T[] data;
    int N;

public:
    this(T[] a){
        data = [0] ~ a[];
        N = a.length.to!int;

        foreach (i ; 1 .. N + 1) {
            if (i + (i & (-i)) <= N) {
                data[i + (i & (-i))] += data[i];
            }
        }
    }

    void add(int i, T x) {
        i++;

        while (i <= N) {
            data[i] += x;
            i += i & (-i);
        }
    }

    T getSum(int r) {
        T res;

        while(r > 0){
            res += data[r];
            r -= r & (-r);
        }

        return res;
    }

    void print(){
        stderr.writefln("%(%s %)", data);
    }
}


void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}

Measured memory_bytes: 5028
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N,A;
	int[] x;
	long[][][] dp;
	public void solve() {
		N = nextInt();
		A = nextInt();
		x = new int[N];
		for(int i = 0;i < N;i++){
			x[i] = nextInt();
		}
		dp = new long[N + 1][2500 + 1][50 + 1];
		dp[0][0][0] = 1;
		for(int i = 0;i < N;i++){
			for(int j = 2500;j >= 0;j--){
				for(int k = 0;k < N;k++){
					if(j + x[i] <= 2500){
						dp[i + 1][j + x[i]][k + 1] += dp[i][j][k];
					}
					dp[i + 1][j][k] += dp[i][j][k];
				}
			}
		}
		long ans = 0;
		for(int j = 0;j <= 2500;j++){
			for(int k = 1;k <= N;k++){

				if(j % k == 0 && j / k == A){
					ans += dp[N][j][k];
				}
			}
		}
		out.println(ans);
	}

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

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 77392
#include <iostream>
#include <vector>
#include <cmath>
 
using namespace std;
int H,A;

int main()
{
  int n;
  cin >> H >> A;
  n = H/A;
  if (H%A==0)
    printf("%d\n", H/A);
  else
    printf("%d\n", H/A+1);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int townNum = scan.nextInt();
        long loveInt = scan.nextLong();
        Town[] towns = new Town[townNum + 1];
        for (int i = 1; i < townNum + 1; i++) {
            towns[i] = new Town(i);
        }

        for (int i = 1; i < townNum + 1; i++) {
            towns[i].setNextTown(towns[scan.nextInt()]);
        }

        towns[1].reach(1);
        Town endTown = towns[1].endlessGoNext();

        int startLoop=endTown.goNext().getFirstReach();
        int loop=endTown.getFirstReach()-startLoop+1;

        long minStep=loveInt;
        if (loveInt>startLoop){
            minStep=(loveInt-startLoop) % loop+startLoop;
        }

        Town end=towns[1];
        for (int i = 0; i <minStep ; i++) {
            end=end.goNext();
        }

        System.out.println(end.getId());
    }
}

class Town {
    private final int id;
    private int firstReach = 0;
    private Town nextTown;

    public Town(int id) {
        this.id = id;
    }

    public int getId() {
        return id;
    }

    public void setNextTown(Town nextTown) {
        this.nextTown = nextTown;
    }

    public boolean reach(int firstReach) {
        if (this.firstReach == 0) {
            this.firstReach = firstReach;
            return true;
        } else {
            return false;
        }
    }

    public int getFirstReach() {
        return firstReach;
    }

    Town goNext() {
        return nextTown;
    }

    Town endlessGoNext() {
        if (nextTown.reach(firstReach + 1)) {
            return nextTown.endlessGoNext();
        } else {
            return this;
        }
    }
}


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

int main(){
	int n,m;
	int i;
	int ans;
	
	cin >> n >> m;
	
	for(int i = ceil(m*1.0/n);i >= 1;i--){
		if(m%i==0&&m/i>=n){
			ans = i;
			break;
		}
	}
	
	cout << ans << endl;
}

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

#define ll long long


using namespace std;
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a > b)
        swap(a, b);
    if (c > d)
        swap(c, d);
    if (a > c) {
        swap(a, c);
        swap(b, d);
    }

    cout << max(0ll, min(b, d) - c);
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}


int main(void) {
    int N; cin >> N;
    vector<int> A(N+1);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    A[N] = 1000000007;
    
    int ans = 0;
    int cnt = 0;
    for (int i = 1; i <= N; i++) {
        if (A[i-1] >= A[i]) {
            cnt++;
        } else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ull unsigned long long
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


ll dp[100005];
ll weight[105];
ll value[105];

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

    ll ww, vv;
    ll tot_val = 0;
    for(int i=0;i<n;i++)
    {
        cin >> weight[i] >> value[i];
        tot_val += value[i];
    }

    ll ans = 0;
    
    for(int i=0;i<100005;i++)
        dp[i] = 1e18L;

    dp[0] = 0;

    for(int i=0;i<n;i++)
    {
        for(int cur_val = tot_val-value[i]; cur_val>=0; cur_val--)
        {
            dp[cur_val + value[i]] = min( dp[cur_val] + weight[i], dp[cur_val+value[i]] );
        }
    }
        
    for(int i=0;i<tot_val+1;i++)
        if(dp[i] <= w)
            ans = max(ans, (ll)i);

    cout << ans << endl;

    

}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

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

	long x = in.nextLong();
	long ans = 0;

	ans = (x / 11) * 2;

	if(x % 11 == 0){

	}
	else if(x % 11 < 7){
		ans = ans + 1;
	}else{
		ans = ans + 2;
	}

	System.out.print(ans);

	}

}

Measured memory_bytes: 23636
using System;




class A
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());

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

            string[] s = Console.ReadLine().Split(' ');

            double xa = double.Parse(s[0]);
            double ya = double.Parse(s[1]);
            double ra = double.Parse(s[2]);
            double xb = double.Parse(s[3]);
            double yb = double.Parse(s[4]);
            double rb = double.Parse(s[5]);

            double distance = Math.Sqrt(Math.Pow(xb - xa, 2) + Math.Pow(yb - ya, 2));

            if (distance > ra + rb)
            {
                Console.WriteLine("0");
            }
            else if (distance + rb < ra )
            {
                Console.WriteLine("2");
            }
            else if (distance + ra < rb)
            {
                Console.WriteLine("-2");
            }
            else
            {
                Console.WriteLine("1");
            }
        }
    }
}

Measured memory_bytes: 5656
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

inline int safeAdd(int a, int b, int m) {
	if ((long long)a + b >= m) {
		return m + ((long long)a + b) % m;
	} else {
		return a + b;
	}
}

inline int safeMul(int a, int b, int m) {
	if ((long long)a * b >= m) {
		return m + (long long)a * b % m;
	} else {
		return a * b;
	}
}

int powSum(int x, int n, int MOD) {
	if (n == 0) {
		return 0;
	}
	int ret = 0, s = 1, t = 1;
	while (n) {
		if (n & 1) {
			ret = safeAdd(ret, safeMul(s, t, MOD), MOD);
			s = safeMul(s, x, MOD);
		}
		t = safeMul(t, safeAdd(x, 1, MOD), MOD);
		x = safeMul(x, x, MOD);
		n >>= 1;
	}
	return ret;
}

int phi(int n) {
	int ret = 1;
	for (int i = 2; i * i <= n; ++i) {
		if (n % i == 0) {
			ret *= (i - 1);
			n /= i;
			while (n % i == 0) {
				ret *= i;
				n /= i;
			}
		}
	}
	if (n != 1) {
		ret *= (n - 1);
		n = 1;
	}
	return ret;
}

int l;

int getb(int n, int mp, int mq) {
	int m = mp * mq;
	if (n == 1) {
		return 1;
	}
	do {
		int g = __gcd(mq, l - 1);
		if (g == 1) {
			break;
		}
		mp *= g, mq /= g;
	} while (true);
	int bn1;
	if (mq == 1) {
		bn1 = 1;
		for (int i = 2; i < n; ++i) {
			int last = bn1;
			bn1 = safeMul(2, powSum(l, bn1, m), m);
			if (bn1 == last) {
				break;
			}
		}
	} else {
		bn1 = getb(n - 1, mp, phi(mq));
	}
	return safeMul(2, powSum(l, bn1, m), m);
}

int main() {
	int n, m;
	while (scanf("%d%d%d", &n, &m, &l) == 3 && l) {
		int ans;
		if (n == 0) {
			ans = 1 % m;
		} else if (n == 1) {
			ans = l % m;
		} else {
			int bn = getb(n, 1, m);
			ans = ((long long)(l - 1) * bn + 1) % m;
		}
		static int id = 0;
		printf("Case %d: %d\n", ++id, ans);
	}
	return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>
#include <malloc.h>
#include <string.h>

#define DEL_1ST  "deleteFirst"
#define DEL_LAST "deleteLast"
#define DELETE "delete"
#define INSERT "insert"

struct _node{
	struct _node *prev ;
	struct _node *next ;
	int val ;
} ;

void print_list(struct _node *top) {
	struct _node *node ;
	for (node = top; node; node = node->next) {
		printf("%d ", node->val) ;
	}
	printf("\n") ;
}

void free_top(struct _node **top, struct _node **bot) {
	struct _node *free_node = *top ;
	*top = (*top)->next ;
	if (!*top) *bot = NULL ;
	else (*top)->prev = NULL ;
	free (free_node) ;
	//print_list(*top) ;
}

void free_bot(struct _node **top, struct _node **bot) {
	struct _node *free_node = *bot ;
	*bot = (*bot)->prev ;
	if (!*bot) *top = NULL ;
	else (*bot)->next = NULL ;
	free (free_node) ;
	//print_list(*top) ;
}

void insert_node(int val, struct _node **top, struct _node **bot) {
	struct _node *node ;

	node = malloc(sizeof(struct _node)) ;
	if (*top) (*top)->prev = node ;
	node->val = val ;
	node->next = *top ;
	node->prev = NULL ;
	*top = node ;
	if (!*bot) *bot = node ;
	//print_list(*top) ;
}

void free_mid(struct _node *node) {
	node->next->prev = node->prev ;
	node->prev->next = node->next ;
	free(node) ;
}

void free_node(int val, struct _node **top, struct _node **bot) {
	struct _node *node ;
	for (node = *top; node; node = node->next) {
		if (node->val == val) {
			if (node == *top) free_top(top, bot) ; 
			else if (node == *bot) free_bot(top, bot) ; 
			else free_mid(node) ;
			return ;
		}
	}
}

int main(void) {
	int i ;
	struct _node *node ;
	struct _node *top =  NULL ;
	struct _node *bot = NULL ;
	char buf[100] ;
	int n ;

	fscanf(stdin, "%d\n", &n) ;
	for (i=0; i<n; i++) {
		fgets(buf, sizeof(buf), stdin) ;
		//printf("%s", buf) ;

		if (!strncmp(buf, DEL_1ST, sizeof(DEL_1ST)-1)) {
			//printf("delFirst %d\n", top->val) ;
			free_top(&top, &bot) ;
		}
		else if (!strncmp(buf, DEL_LAST, sizeof(DEL_LAST)-1)) {
			//printf("delLast %d\n", bot->val) ;
			free_bot(&top, &bot) ;
		}
		else {
			char cmd[100] ;
			int val ;

			sscanf(buf, "%s %d", cmd, &val) ;
			if (!strncmp(cmd, INSERT, sizeof(INSERT))) {
				insert_node(val, &top, &bot) ;
			}
			else if (!strncmp(cmd, DELETE, sizeof(DELETE))) {
				free_node(val, &top, &bot) ;
			}
			else printf("Unexpected input %s\n", buf) ;
		}
	}

	for (node = top; node; node = node->next) {
		if (node != bot) printf("%d ", node->val) ;
		else printf("%d\n", node->val) ;
	}
}



Measured memory_bytes: 32968
#include <iostream>
#include <cfloat>

double min(double x, double y)
{
	return x>y ? y : x;
}

int main()
{
	std::string strn; getline(std::cin, strn);
	int n = std::stoi(strn);
	
	double *p = new double[n];
	double *q = new double[n+1];
	
	for (int i=0; i<n; i++) std::cin >> p[i];  // p[0], p[1], ... , p[n-1]
	for (int i=0; i<=n; i++) std::cin >> q[i]; // q[0], q[1], ... , q[n-1], q[n]
	
	double *cost_sum = new double[n+1];
	cost_sum[0] = q[0];
	for (int i=1; i<n+1; i++) cost_sum[i] = cost_sum[i-1] + p[i-1] + q[i]; 
	
	double** DP = new double*[n+1];
	for (int i=0; i<n+1; i++) DP[i] = new double[n];
	
	for (int j=0; j<n; j++) DP[j+1][j] = 0.0;
	
	for (int d=0; d<n; d++) {
		for (int i=0; i<n-d; i++) {
			if (d==0) DP[i][i] = q[i] + q[i+1];
			else {
				DP[i][i+d] = DBL_MAX;
				for (int j=0; j<=d; j++) {
					double left_cost_sum  = cost_sum[i+j] - cost_sum[i] + q[i];
					double right_cost_sum = cost_sum[i+d+1] - cost_sum[i+j+1] + q[i+j+1];
					DP[i][i+d] = min(DP[i][i+d], DP[i][i+j-1] + left_cost_sum + DP[i+j+1][i+d] + right_cost_sum);
				}
			}
			// std::cout << "DP[" << i << "][" << i+d << "] = " << DP[i][i+d] << std::endl;
		}
	}
	
	std::cout << std::fixed << DP[0][n-1] + 1 << std::endl;
	
	for (int i=0; i<n; i++) delete[] DP[i];
	delete[] DP;
	delete[] cost_sum;
	delete[] p;
	delete[] q;
	
	return 0;
}



Measured memory_bytes: 5264
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,ans;
    cin>>a>>b;
    if(a > 0 && b > 0) cout<<"Positive"<<endl;
     else if (max(a, b) >= 0 && min(a, b) <= 0 || a == 0 || b == 0) cout<<"Zero"<<endl;
     else {
        if ((abs(min(a, b)) - abs(max(a, b))) % 2 == 0) {
            cout << "Negative" << endl;
        } else {
            cout << "Positive" << endl;
        }
    }
    return 0;
}

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

int main(){
  ll a;
  string s;
  cin>>a>>s;
  if(a>=3200){
    cout<<s<<endl;
  }else{
    cout<<"red"<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	string s;
	cin >> s;
	if (s == "ABC") cout << "ARC\n";
	else cout << "ABC\n";
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a%2!=b%2){
    puts("IMPOSSIBLE");
    return 0;
  }
  int ans = (a+b)/2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 29)
using namespace std;

int main(){
    long long a, b, c;
    long long ans;
    cin >> a >> b >> c;
    if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
        ans = 0;
    }else{
        if(a >= b && a >= c){
            ans = b * c;
        }else if(b >= a && b >= c){
            ans = a * c;
        }else{
            ans = a * b;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string N;
  cin >> N;
  long sum=0;
  for(int i=0;i<(int)(N.size());i++){
    char c = N.at(i);
    int n= c-'0';
    sum+=n;
  }
  //cout << sum << endl;
  if(sum%9 == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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(){
    int n;
    cin >> n;
    V<int> cat(101);
    stack<int> st;
    Rep(i,n) {
        int a;
        cin >> a;
        bool ok = true;
        if(cat[abs(a)] && a > 0) ok = false;
        if(!cat[abs(a)]&& a < 0) ok = false;
        if(a > 0) st.push(a);
        else {
            if(!sz(st))
                ok = false;
            else {
                int b = st.top(); st.pop();
                if(abs(a) != b) ok = false;
            }
        }
        cat[abs(a)] = ~cat[abs(a)];
        if(!ok) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "OK" << endl;
}


Measured memory_bytes: 3112
import itertools

N, M, Q = map(int, input().split())
ABCD = [list(map(int, input().split())) for _ in range(Q)]

max_score = 0

for A in itertools.combinations_with_replacement(range(1, M + 1), N):
    score = 0
    for a, b, c, d in ABCD:
        if A[b - 1] - A[a - 1] == c:
            score += d
    max_score = max(max_score, score)

print(max_score)


Measured memory_bytes: 9188
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

// Dijkstra<ll> d(n); 頂点数n

  

int main() {
  double a,b,n, m, x, y = 0, z = 0, h, w, ans = 0, sum = 0, Max = -1, Min = 1e9+1;
  string s, t, u;
  bool ok=true;
  cin >>a >> b >> h >> m;
  x = h*30 + m*0.5;
  y = m * 6;
  if(x>y){
    x -= y;
    z = x;
  }
  else{
    y -= x;
    z = y;
  }
  z = z*M_PI/180;
  ans = pow(a,2) + pow(b,2) - (2*a*b*cos(z));
  cout << setprecision(15) << sqrt(ans) << endl;

  return 0;
}


Measured memory_bytes: 4236
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        int cnt = 0;

        if (A == B)
            cnt++;

        if (A == C)
            cnt++;

        if (B == C)
            cnt++;

        if (cnt == 1)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
#define pb push_back
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;


int main(){
  int n, m;
  cin >> n >> m;
  vector<int> e[n];
  int d[n][3];
  rep(i, n) fill(d[i], d[i] + 3, INF);
  rep(i, m){
    int u, v;
    cin >> u >> v;
    u--; v--;
    e[u].push_back(v);
  }
  int s, t;
  cin >> s >> t;
  s--;t--;
  d[s][0] = 0;
  bool checked[n][3];
  rep(i, n) fill(checked[i], checked[i] + 3, false);
  queue<int> q;
  q.push(s);
  while(!q.empty()){
    int from = q.front();
    q.pop();
    for(int x : e[from]){
      if(checked[x][1] && d[x][1] <= d[from][0] + 1) continue;
      checked[x][1] = true;
      d[x][1] = min(d[from][0] + 1, d[x][1]);
      for(int y : e[x]){
        if(checked[y][2] && d[y][2] <= d[from][0] + 1) continue;
        checked[y][2] = true;
        d[y][2] = min(d[from][0] + 1, d[y][2]);
        for(int z : e[y]){
          if(checked[z][0] && d[z][0] <= d[from][0] + 1) continue;
          d[z][0] = min(d[from][0] + 1, d[z][0]);
          checked[z][0] = true;
          q.push(z);
        }
      }
    }
  }
  if(d[t][0] == INF) d[t][0] = -1;
  cout << d[t][0] << endl;
}
                    

Measured memory_bytes: 10536
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Scanner;

// Aizu 0009
public class Main {

	private Main(){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			int n = in.nextInt();
			System.out.println(calcPrimeNum(n));
		}
	}

	public int calcPrimeNum(int limit){
		BitSet sieve = new BitSet(limit+1);
		ArrayList<Integer> primeList = new ArrayList<Integer>();
		for(int i=2;i<=limit;i++){
			if(!sieve.get(i)){
				primeList.add(i);
				int j = i;
				while(j<=limit){
					sieve.set(j, true);
					j+=i;
				}
			}
		}
		return primeList.size();
	}

	public static void main(String[] args) {
		new Main();
	}

}

Measured memory_bytes: 17000
x = int(input())

q = x // 11

if x <= 6:
    print(1)
elif 6 < x <= 11:
    print(2)
elif x % 11 == 0:
    print(2 * q)
elif x % 11 < 7:
    print(q * 2 + 1)
elif x % 11 >= 7:
    print((q + 1) * 2)


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

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

    string s[n];
    rep(i, n){
        cin >> s[i];
    }

    sort(s[0].begin(), s[0].end());
    map<char, ll> st;
    map<char, ll> st_new;

    rep(i, s[0].size()){
        st[s[0][i]]++;
        st_new[s[0][i]]++;
    }

    for(pair<char, ll> str: st){
        for(int i = 1; i < n; i++){
            ll count = 0;
            rep(j, s[i].size()){
                if(str.first == s[i][j]) count++;
            }
            str.second = min(str.second, count);
            st_new[str.first] = str.second;
        }
    }

    for(pair<char, ll> str: st_new){
        rep(i, str.second){
            cout << str.first;
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define elif(a) else if(a)
#define INF INT_MAX
#define F first
#define S second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  float t;
  cin>>a>>b>>t;
  cout<<(int)(t+0.5)/a*b<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main() {
    ll n, a[100010], zeroes = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0) zeroes++;
    }
    
    sort(a, a + n);
    
    ll ans_x[100010], ans_y[100010], plus_from = n, minus_until = -1;
    
    for (int i = 0; i < n; i++) {
        if (a[i] < 0) minus_until = i;
        if (a[i] > 0) {
            plus_from = i;
            break;
        }
    }
    
    ll mn = a[0], mx = a[n - 1], idx = 0;
    for (int i = 0; i < min(plus_from - 1, n - 2); i++) {
        ans_x[idx] = mx;  ans_y[idx] = a[i + 1];
        if (idx == 0) mx = a[n - 1] - a[i + 1];
        else mx = mx - a[i + 1];
        idx++;
        //cout << "mx " << idx << endl;
    }
    for (int i = n - 2; i >= max(plus_from, 1ll); i--) {
        ans_x[idx] = mn;  ans_y[idx] = a[i];
        if (i == n - 2) mn = a[0] - a[i];
        else mn = mn - a[i];
        idx++;
        //cout << "mn " << idx << endl;
    }
    ans_x[idx] = mx;
    ans_y[idx] = mn;
    
    cout << mx - mn << endl;
    for (int i = 0; i < n - 1; i++) cout << ans_x[i] << " " << ans_y[i] << endl;
    
}

Measured memory_bytes: 4224
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

s = ni()

v = 10 ** 9
x = (v - s % v) % v
y = (s + x) // v
print(0, 0, v, 1, x, y)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
    int n, h, w;
    int count = 0;

    cin >> n >> h >> w;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i + h <= n && j + w <= n) {
                count++;
            }
        }
    }

    cout << count << endl;

    return 0;
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

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


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

a,b,c=map(int,input().split())
k=int(input())
for _ in range(k):
    if a>=b:
        b*=2
    else:
        if b>=c:
            c*=2

if a<b and b<c:
    print('Yes')
else:
    print('No')

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

using namespace std;
vector<long long> factors;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);


int main()
{
	IOS

	set<ll> s;
	int n;

	cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);

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

	for (int i = 0; i < n; ++i)
	{
		cin >> b[i];
	}
	vector<ll> low;
	vector<ll> high;
	for (int i = 0; i < n; ++i)
	{
		if (a[i] - b[i] < 0)
		{
			low.push_back(a[i] - b[i]);
		} else if (a[i] - b[i] > 0)
		{
			high.push_back(a[i] - b[i]);
		}
	}

	sort(all(high),[]( ll a,ll b){
		return a < b;
	});
	sort(all(low),[](ll a,ll b){
		return a > b;
	});
	int counter = 0;
	bool flag = true;
	while(low.size() > 0 && high.size() > 0){
		if(high[high.size()-1] + low[low.size() - 1] > 0){
			if(flag)
			{
				++counter;
				flag = false;
			}
			high[high.size()-1] += low[low.size() - 1];
			low.pop_back();
			++counter;
		}else if(high[high.size()-1] + low[low.size() - 1] == 0){
			high.pop_back();
			low.pop_back();
			if(flag)
				++counter;
			counter +=1;
		}else{

			low[low.size() - 1] += high[high.size()-1];
			high.pop_back();
			flag = true;
		}
	}
	if(low.size() == 0)
		cout << counter;
	else
		cout << -1;

	return 0;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int upper = 2 * 2 * 2;

    string S; cin >> S;
    vector<int> a(4);
    for (int i = 0; i < 4; i++) a[i] = S[i] - '0';

    for (int b = 0; b < upper; b++) {
        int tmp = a[0];
        string ans = to_string(a[0]);
        for (int i = 0; i < 3; i++) {
            if ((b >> i) & 1) {
                tmp += a[i + 1];
                ans += "+" + to_string(a[i + 1]);
            }
            else {
                tmp -= a[i + 1];
                ans += "-" + to_string(a[i + 1]);
            }
        }
        if (tmp == 7) {
            cout << ans + "=7" << '\n';
            return 0;
        }
    }
}


Measured memory_bytes: 256
n, q = list(map(int, input().split()))
works = []
for i in range(n):
    works.append(list(input().split()))

count = 0
while len(works) != 0:
    work = works.pop(0)
    time = int(work[1])
    if time > q:
        count += q
        work[1] = time - q
        works.append(work)
    else:
        count += time
        print(work[0] , count)

Measured memory_bytes: 16660
#include <iostream>
#include <cstdio>

using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

typedef long long ll;

int dp[64][64];

int main(){
    int H,W;
    while(cin >> H >> W){
        char g[64][64];
        rep(i,64)rep(j,64) dp[i][j] = 1e8;
        dp[0][0] = 0;
        rep(i,H) cin >> g[i];
        rep(i,H){
            rep(j,W){
                int d = g[i][j]-'0';
                dp[i][j+1] = min(dp[i][j+1], dp[i][j] + d);
                dp[i+1][j] = min(dp[i+1][j], dp[i][j] + d);
            }
        }
        cout << dp[H-1][W-1] << endl;
    }
}

Measured memory_bytes: 1184
#include <stdio.h>
#include <cstring>
#include <stdlib.h>
int main ()
{
	int n,r=0;
	scanf("%i",&n);
	char s[n+1];
	scanf("%s",&s);
	if(n%2!=0)
	{
		printf("No");
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		if(s[i]==s[(n/2)+i])
		{
			r++;
		}
	}
	if(r==n/2)
	{
		printf("Yes");
		return 0;
	}
	else printf("No");
	return 0;
}


Measured memory_bytes: 128
#create date: 2020-08-02 21:00

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    x = ni()
    print("Yes" if x >= 30 else "No")

if __name__ == "__main__":
    main()

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

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(s) (s).begin(), (s).end()
const ll MOD = 1e9 + 7;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    string s;
    cin >> s;
    if (s.compare("BBB") == 0 || s.compare("AAA") == 0)
        cout << "No";
    else
    {
        cout << "Yes";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,n;
    cin>>N>>n;
    for(int i=0,ai,bi;i<n;i++){
        cin>>ai>>bi;
        if(ai>(N+1)/2)ai=N-ai+1;
        if(bi>(N+1)/2)bi=N-bi+1;
        if(ai%3==1&&bi-ai>=0&&N-bi>=3*(ai/3)||
           bi%3==1&&ai-bi>=0&&N-ai>=3*(bi/3))cout<<"1\n";
        else if(ai%3==2&&bi-ai>=0&&N-bi>=3*(ai/3)-1||
                bi%3==2&&ai-bi>=0&&N-ai>=3*(bi/3)-1)cout<<"2\n";
        else cout<<"3\n";
    }
}

Measured memory_bytes: 1120
import statistics


if __name__ == "__main__":
    stdevs = []

    while True:
        num_students = int(input())

        if num_students == 0:
            break

        scores = list(map(int, input().split()))

        s = statistics.pstdev(scores)

        stdevs.append(s)

    for s in stdevs:
        print(s)


Measured memory_bytes: 7080
s = list(input())
t = list(input())
checker = 0
for i in range(len(s)-len(t), -1, -1):
    if all(s[i+j]==t[j] or s[i+j]=="?" for j in range(len(t))):
        checker = 1
        for j in range(len(t)):
            s[i+j] = t[j]
        s = ["a" if s[I]=="?" else s[I] for I in range(len(s))]
        break
if checker:
    print("".join(s))
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064