akhauriyash/Code-Regression huggingface dataset:
# https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_a



X, Y = gets.split.map(&:to_i)
ans=0
if X==1 
    ans+=300000
end
if X==2
    ans+=200000
end
if X==3
    ans+=100000
end
if Y==1 
    ans+=300000
end
if Y==2
    ans+=200000
end
if Y==3
    ans+=100000
end
if X==1 && Y==1
    ans+=400000
end
puts ans


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

int main() {
  int x1,x2,x3,x4,x5;
  cin>>x1>>x2>>x3>>x4>>x5;
    if(x1 == 0) {
     cout << 1 << endl;
    }
    if(x2 == 0) {
     cout << 2 << endl;
    }
    if(x3 == 0) {
     cout << 3 << endl;
    }
    if(x4 == 0) {
     cout << 4 << endl;
    }
    if(x5 == 0) {
     cout << 5 << endl;
    }
}

Measured memory_bytes: 3620
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int x=sc.nextInt();
    int a=sc.nextInt();
    int b=sc.nextInt();
    System.out.println(Math.abs(a-x)>Math.abs(b-x)?"B":"A");
  }
}


Measured memory_bytes: 21844
N = int(input())
S = input()

ans = 0
for d1 in "0123456789":
    p1 = S.find(d1)
    if p1 == -1: continue

    for d2 in "0123456789":
        p2 = S[p1+1:].find(d2)
        if p2 == -1: continue

        for d3 in "0123456789":
            if d3 in S[p1+p2+2:]:
                ans += 1

print(ans)



Measured memory_bytes: 9268
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long tk=sc.nextLong();
		long ao=sc.nextLong();
		int kaisu=sc.nextInt();

		int cnt=1;
		for(int i=0; i<kaisu; i++) {
			if(cnt==1) {
				if(tk%2==0) {
					ao+=tk/2;
					tk/=2;
				}
				else if(tk%2==1) {
					tk--;
					ao+=tk/2;
					tk/=2;

				}
				cnt*=-1;
			}
			else if(cnt==-1) {
				if(ao%2==0) {
					tk+=ao/2;
					ao/=2;
				}
				else if(ao%2==1) {
					ao--;
					tk+=ao/2;
					ao/=2;
				}
				cnt*=-1;
			}
		}
		System.out.println(Math.max(0, tk)+" "+Math.max(0, ao));
	}
}

Measured memory_bytes: 22612
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.InputStream;

import java.util.Arrays;
import java.util.Comparator;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner fs = new FastScanner();

        final int N = fs.nextInt();

        Integer[] X = new Integer[N];

        for (int i = 0; i < N; i++) X[i] = fs.nextInt();

        Integer[] Y = new Integer[N];

        System.arraycopy(X, 0, Y, 0, X.length);

        Arrays.sort(Y, Comparator.reverseOrder());

        Integer left = Y[N / 2 - 1];
        Integer right = Y[N / 2];

        for (int i = 0; i < N; i++)
            System.out.println(left.compareTo(X[i]) <= 0 ? right : left);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if(b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

#define pb push_back
#define test int TEST;cin>>TEST;while(TEST--)
#define mod 1e9 + 7
#define inf 99999999999
#define neginf -9999999999
#define vi vector<int>
#define vchar vector<char>
#define vstr vector<string> 
#define vsort(xx) sort(xx.begin(),xx.end())
#define vrevsort(xx) sort(xx.rbegin(),xx.rend())

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
   string a,b;
 cin>>a>>b;
 long int l = min(a.size(), b.size());
 long int i=0;
 for(i=0;i<l;i++){
     cout<<a[i]<<b[i];
 }
 if(a.size()>l)
    cout<<a[i];
 if(b.size()>l)
    cout<<b[i];
    
    return 0;
}




Measured memory_bytes: 256
k=int(input())
total=0
def count(keta,s,ans):
    global total
    if keta==1:
        total+=1
        if k==total:
            print(ans) #ここで終了させたい
        return 
    for m in range(10):
        if abs(s-m)<=1:
            count(keta-1,m,ans+str(m))
for i in range(1,11):
    for j in range(1,10):
        count(i,j,str(j))

Measured memory_bytes: 47580
A, B = map(int, input().split())


def gcd(a, b):
    if a < b:
        return gcd(b, a)
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


def lcm(a, b):
    return a * b // gcd(a, b)


print(lcm(A, B))


Measured memory_bytes: 2940
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    if A==B:
        return "Draw"
    elif 1 == A or 1 == B:
        if A==1:
            return "Alice"
        else:
            return "Bob"
    else:
        if A > B:
            return "Alice"
        else:
            return "Bob"

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    print(solve(A, B))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int a[1000], n, i, frag=0;
	scanf("%d", &n);
	
	for(i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	
	for(i=0; i<n; i++){
		if(a[i] % 2 ==0){
			if(a[i] % 3 == 0 || a[i] % 5 == 0){
			}else{
			frag=1;
			}
		}
	}
	
	if(frag==0) printf("APPROVED\n");
	else{
	printf("DENIED\n");
	}
	return 0;
}

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

int main() {
  int N,l,r;
  int sum = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
      cin >> l >> r;
      sum+=r-l+1;
  }
  cout << sum <<  endl;
} 

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

#define lp_ui(k,n) for(ui i = (k); i < (n); ++i)
#define lp_ul(k,n) for(ul i = (k); i < (n); ++i)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

using namespace std;

void solve(void)
{
	ui N{};
	cin >> N;

	typedef pair<ui, ui> mPair;
	vector<mPair> vc_a(N);
	lp_ui(0, N)
	{
		vc_a[i].first = i;
		cin >> vc_a[i].second;
	}

	auto cmp = [](const mPair& x, const mPair& y) {
		return x.second > y.second;
	};

	sort(vc_a.begin(), vc_a.end(), cmp);

	lp_ui(0, N)
	{
		cout << ((vc_a[0].first == i) ? vc_a[1].second : vc_a[0].second) << endl;
	}

	return;
}

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

	solve();

//	auto ans = solve();
//	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>

int main(int argc, char *argv[])
{
  int down[20000];
  int lake[20000][2];
  char c;
  int i = 0;
  int A, k;
  int in[2];
  int left, s;

  in[0] = 0;
  in[1] = 0;

  while ((c = getchar()) != EOF) {
    switch (c) {
    case '\\':
      down[in[0]++] = i;
      break;
      
    case '_':
      break;
      
    case '/':
      if (in[0] == 0) break;
      else {
	left = down[--in[0]];
	s = i - left;
	if (in[1] == 0) {
	  lake[in[1]][0] = left;
	  lake[in[1]][1] = s;
	  in[1]++;
	} else {
	  while (1) {
	    if (in[1] == 0) break;
	    if (lake[in[1] - 1][0] > left) s += lake[--in[1]][1];
	    else break;
	  }
	  lake[in[1]][0] = left;
	  lake[in[1]][1] = s;
	  in[1]++;
	}
      }
      break;

    default:
      break;
    }
    i++;
  }

  A = 0;
  k = in[1];
  for (i = 0; i < k; i++) A += lake[i][1];

  printf("%d\n", A);
  printf("%d", k);
  for (i = 0; i < k; i++) printf(" %d", lake[i][1]);
  printf("\n");

  return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
// head
struct edge { int to, cap, rev, cost; };
vector<edge> G[1000];
void add_edge(int from, int to, int cap, int cost = 0){
	G[from].push_back(edge{ to, cap, (int)G[to].size(),cost });
	G[to].push_back(edge{ from,0,(int)G[from].size() - 1,-cost });
}
 
const int CMAX = 200012;
long long fact[CMAX] = {};
long long revFact[CMAX] = {};
void setFact(int N)
{
  fact[0] = 1;
  for (int i = 1; i<N; i++)
  {
    fact[i] = fact[i-1]*i;
    fact[i] %= mod;
  }
  revFact[N-1] = powmod(fact[N-1],mod-2);
  for (int i=N-2;i>=0;i--)
  {
    revFact[i] = revFact[i+1]*(i+1);
    revFact[i] %= mod;
  }
}
 
long long getC(int a, int b)
{
  return (((fact[a] * revFact[b]) % mod) * revFact[a-b]) % mod;
}
 
int main() {
	  ll H,W,A,B;
    std::cin >> H>>W>>A>>B;
		setFact(CMAX);
		ll ans = 0;
		rep(i,B,W){
			ans += getC(i+H-A-1,H-A-1) * getC(W-1-i+A-1,A-1);
			ans %= mod;
		}
		std::cout << ans << '\n';
}

Measured memory_bytes: 3456
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int N,S,Q;
int A[500001][20][26];
int B[500001];
int ans[26];

int henkan(char s){
    if(s=='a') return 0;
    if(s=='b') return 1;
    if(s=='c') return 2;
    if(s=='d') return 3;
    if(s=='e') return 4;
    if(s=='f') return 5;
    if(s=='g') return 6;
    if(s=='h') return 7;
    if(s=='i') return 8;
    if(s=='j') return 9;
    if(s=='k') return 10;
    if(s=='l') return 11;
    if(s=='m') return 12;
    if(s=='n') return 13;
    if(s=='o') return 14;
    if(s=='p') return 15;
    if(s=='q') return 16;
    if(s=='r') return 17;
    if(s=='s') return 18;
    if(s=='t') return 19;
    if(s=='u') return 20;
    if(s=='v') return 21;
    if(s=='w') return 22;
    if(s=='x') return 23;
    if(s=='y') return 24;
    if(s=='z') return 25;
    else return 0;
}
int main(){
    cin >> N;
    int NN = N;
    for (int i=0;i<N;i++){
        char s;
        cin >> s;
        int a = henkan(s);
        A[i][0][a] = 1;
        B[i] = a;
    }
    int h=1;
    N /= 2;
    while(N>0){
        for(int i=0;i<N;i++){
            for(int k=0;k<26;k++){
                A[i][h][k] = A[2*i][h-1][k] + A[2*i+1][h-1][k];
            }
        }
        N/=2;
        h++;
    }
    
    cin >> Q;
    for(int i=0;i<Q;i++){
        int a;
        cin >> a;
        if (a == 1){
            int b;
            char c;
            cin >> b >> c;
            int d = henkan(c);
            int e = B[b-1];
            B[b-1] = d;
            int bb = b;
            int j=0;
            int NNN = NN;
            while(bb<=NNN){
                A[bb-1][j][e] -= 1;
                A[bb-1][j][d] += 1;
                bb = (bb+1)/2;
                NNN /= 2;
                j++;
            }
        } else {
            int b,c;
            cin >> b >> c;
            int k=0;
            while(c>0){
                if(c%2==1){
                    for(int j=0;j<26;j++){
                        ans[j] += A[c-1][k][j];
                    }
                }
                k++;
                c/=2;
            }
            k = 0;
            b = b-1;
            while(b>0){
                if(b%2==1){
                    for(int j=0;j<26;j++){
                        ans[j] -= A[b-1][k][j];
                    }
                }
                k++;
                b/=2;
            }
            
            int kai = 0;
            for(int j=0;j<26;j++){
                if(ans[j] != 0){
                    kai++;
                    ans[j] = 0;
                }
            }
            cout << kai << endl;
        }
        
    }
    

}




Measured memory_bytes: 1017856
local n, x, y = io.read("*n", "*n", "*n")
local t = {}
for i = 1, n - 1 do
  t[i] = 0
end
local mab = math.abs
local mmi, mma = math.min, math.max
for i = 1, n - 1 do
  for j = i + 1, n do
    -- i j
    local cand = j - i
    -- i x y j
    cand = mmi(cand, mab(i - x) + 1 + mab(j - y))
    t[cand] = t[cand] + 1
  end
end
for i = 1, n - 1 do
  print(t[i])
end


Measured memory_bytes: 888
from math import ceil,floor
n=int(input())
a=list(map(int,input().split()))
ave=sum(a)/n
ave1=ceil(ave)
ave2=floor(ave)
inf=10**10
ans1,ans2=0,0
for aa in a:
  ans1+=(aa-ave1)**2
  ans2+=(aa-ave2)**2
print(min(ans1,ans2))
  

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

#define MAX_N 100
#define MAX_W 10000

void solve();

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

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

  // 品物０
  v[0] = 0;
  w[0] = 0;

  // 品物１〜
  for(int i = 1; i <= N; i++) cin >> v[i] >> w[i];

  solve();
  cout << dp[N][W] << endl;

  return 0;
}

void solve() {
for (int i = 1; i <= N; i++) {          //品物1からスタート
        for (int j = 0; j <= W; j++) {
            if (j < w[i]) {                 //容積 j に品物 i が入らないとき.
                dp[i][j] = dp[i-1][j];
            }else{                          //容積 j（現在の容積）に品物 i（現在の品物）が入るとき.
                dp[i][j] = max( dp[i-1][j], dp[i-1][j-w[i]]+v[i] );
            }
        }
    }
  }



Measured memory_bytes: 7016
import numpy as np

MOD = 10 ** 9 + 7

N = int(input())
A = np.array(list(map(int, input().split())))

ans = 0
for n in range(62):
    B = (A >> n) & 1
    x = np.count_nonzero(B)
    y = N - x
    mul = x * y
    for _ in range(n):
        mul *= 2
        mul %= MOD
    ans += mul

ans %= MOD
print(ans)


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

int main()
{
	int n, a;
	cin >> n;
	a = n %	10;
	
	if (a==2 || a==4 || a==5 || a==7 || a==9)
		cout << "hon";
	else if(a==0 || a==1 || a==6 || a==8)
		cout << "pon";
	else
		cout << "bon";
	return 0;
}

Measured memory_bytes: 3632
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

int dp[1003][20004];
signed main() {
  rep(i, 0, 1003) rep(j, 0, 20004) dp[i][j] = INF;
  int H, N;
  cin >> H >> N;
  vi A(N), B(N);
  rep(i, 0, N) { cin >> A[i] >> B[i]; }
  dp[0][0] = 0;
  rep(i, 0, N) {
    rep(j, 0, H + 10002) {
      if (j - A[i] >= 0) {
        chmin(dp[i + 1][j], dp[i + 1][j - A[i]] + B[i]);
      }
      chmin(dp[i + 1][j], dp[i][j]);
    }
  }
  int ans = INF;
  rep(i, H, 20004) { chmin(ans, dp[N][i]); }
  cout << ans << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 157056
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int r;
  cin>>r;
  double ans=(double)2*(double)((double)22/(double)7)*(double)r;
  cout<<ans<<"\n";
  
}

Measured memory_bytes: 3240
from bisect import bisect_left
from bisect import bisect_right

n,m = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)

a_count = [0]*100010
a_sum = [0]*100010

for i in range(n):
    a_count[a[i]] += 1
    a_sum[a[i]] += a[i]

for i in range(100005,-1,-1):
    a_count[i] += a_count[i+1]
    a_sum[i] += a_sum[i+1]

def chk(x):
    case = 0
    for i in range(n):
        if 0<= x-a[i]<= 10**5+5:
            case += a_count[x-a[i]]
        elif x-a[i] < 0:
            case += n
    if case >= m:
        ch = True
    else:
        ch = False
    return ch

l = 2*a[-1]+1    #NG
r = 1 #OK

while abs(r-l) > 1:
    kk = (r+l)//2
    if chk(kk):
        r = kk
    else:
        l = kk

ans = 0
sm = sum(a)

l = r

case = 0
for i in range(n):
    num = n-bisect_right(a,l-a[i]-1)
    case += num
    ans += num*a[i]*2

ans -= (case-m)*l

print(ans)

Measured memory_bytes: 55448
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
#define ll long long
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int a, b;

signed main() {
	cin >>a >> b;
	if (a >= 13)cout << b << endl;
	else if (a >= 6)cout << b / 2 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	int mi=inf,sum=0;
	rep(i,n){
		int a;cin>>a;
		if(a%10)mi=min(mi,a);
		sum+=a;
	}
	if(sum%10==0){
		if(mi==inf){
			sum=0;
		}else sum-=mi;
	}
	cout<<sum<<endl;
}





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

const int maxn = 500+10;

const int dr[] = {-1,0,1,0};
const int dc[] = {0,1,0,-1};

char save[maxn][maxn];
int R,C;
char A[maxn][maxn];
char B[maxn][maxn];

int main()
{
    //freopen("./test.txt","r",stdin);
    scanf("%d %d",&R,&C);
    for(int i = 1;i <= R;++i)
        scanf("%s",save[i]+1);

    for(int i = 1;i <= R;++i)
    {
        for(int j = 1;j <= C;++j)
        {
            A[i][j] = '.';
            B[i][j] = '.';
            if(save[i][j] == '#')
            {
                A[i][j] = '#';
                B[i][j] = '#';
            }
        }
        A[i][C+1] = 0;
        B[i][C+1] = 0;
    }
    for(int i = 1;i <= R;++i)
    {
        A[i][1] = '#';
        B[i][C] = '#';
        if(i % 2 == 1)
        {
            for(int j = 2;j <= C-1;++j)
                A[i][j] = '#';
        }
        else
        {
            for(int j = 2;j <= C-1;++j)
                B[i][j] = '#';
        }

    }


    for(int i = 1;i <= R;++i)
        puts(A[i]+1);
    putchar('\n');
    for(int i = 1;i <= R;++i)
        puts(B[i]+1);


    return 0;
}


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

int main() {
	int k, s;
	cin >> k >> s;
	int ans = 0;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			int z = s - x - y;
			if (z >= 0 && z <= k) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 33003;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
using namespace std;

int main(){
int n,m;
cin>>n>>m;
vector<string> r(n),b(n),p(n);
rep(i,0,n)
cin>>p[i];
rep(i,0,n)
{
	rep(j,0,m)
	{
		if(i%2==0)
		{
		
			  b[i].push_back('.');
			r[i].push_back('#');
		}
		else
		{
		
			  	b[i].push_back('#');
			  	r[i].push_back('.');

	}
	if(p[i][j]=='#')
	{
		r[i][j]='#';
		b[i][j]='#';
	}
}

}
rep(i,0,n)
{
	r[i][0]='#';
	b[i][m-1]='#';
	r[i][m-1]='.';
	b[i][0]='.';
}
rep(i,0,n)
cout<<r[i]<<endl;
cout<<endl;
rep(i,0,n)
cout<<b[i]<<endl;
}

Measured memory_bytes: 1536
N,M=map(int,input().split())
hen=[0 for i in range(0,N-1)]
for i in range(0,M):
    a,b=map(int,input().split())
    if a==1:
        hen[b-2]+=1
    elif b==1:
        hen[a-2]+=1
    else:
        hen[a-2]+=1
        hen[b-2]+=1

flag=0
for i in range(0,N-1):
    if hen[i]%2==1:
        flag=1

if flag==0:
    print('YES')
else:
    print('NO')


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

using namespace std;

#define endl '\n'

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

  int n;
  cin >> n;
  vector<int> stones(n);
  vector<int> dp(n);
  for (int i = 0; i < n; i++) {
    cin >> stones[i];
  }
  dp[0] = 0;
  dp[1] = abs(stones[0] - stones[1]);
  for (int i = 2; i < n; i++) {
    dp[i] = min(dp[i - 1] + abs(stones[i] - stones[i - 1]), dp[i - 2] + abs(stones[i] - stones[i - 2]));
  }
  cout << dp[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 3904
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

int main(){
  int n; string s; cin >> n >> s;
  int ans = 0;
  for(int i = 0; i < 1000; i++) {
    string t = to_string(i);
    while(t.size() < 3) t = '0' + t;
    bool ok = false;
    int j = 0;
    for(int k = 0; k < n; k++) {
      if(s[k] == t[j]) j++;
      if(j == 3){
        ok = true;
        break;
      }
    }
    if(ok){
      ans++;
      //cout << t << endl;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(int i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<int, int>
#define pb push_back
#define ll long long
#define ld long double	
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e18
ll power(ll num, ll g, ll mod) {
	if (g == 0)return 1;
	if (g % 2 == 1)return (num * power((num * num) % mod, g / 2, mod)) % mod;
	return power( (num * num) % mod, g / 2, mod);
}

int main(){
	sync
	int h, w, k, x1, y1, x2, y2;
	cin >> h >> w >> k;
	cin >> x1 >> y1 >> x2 >> y2;
	int visited[h+1][w+1];
	memset(visited, -1, sizeof(visited));
	string x[h];
	FOR0(i, h) cin>> x[i];
	char pond[h+1][w+1];
	FOR1(i, h){
		FOR1(j, w){
			pond[i][j] = x[i-1][j-1];
		}
	}
	queue<pair<pi, int> > qu;
	qu.push({{x1, y1}, 0});
	visited[x1][y1] =0;
	while(!qu.empty()){
		auto pt = qu.front();
		qu.pop();
		if (visited[x2][y2]!=-1) break;
		int x = pt.ff.ff;
		int y = pt.ff.ss;
		FOR1(i, k) {
			if (x + i > h || pond[x+i][y] == '@') break;
			
			if (visited[x+i][y] == -1){
				visited[x+i][y] = pt.ss + 1;
				qu.push({{x+i, y}, pt.ss + 1});
			}
			else{
				if (visited[x + i][y] < 1 + visited[x][y]) break;
			}
		}
		FOR1(i, k) {
			if (x - i <= 0 || pond[x-i][y] == '@') break;
			
			if (visited[x-i][y] == -1){
				visited[x-i][y] = pt.ss + 1;
				qu.push({{x-i, y}, pt.ss + 1});
			}
			else{
				if (visited[x - i][y] < 1 + visited[x][y]) break;
			}
		}
		FOR1(i, k) {
			if (y + i > w || pond[x][y + i] == '@') break;
			
			if (visited[x][y + i] == -1){
				visited[x][y + i] = pt.ss + 1;
				qu.push({{x, y + i}, pt.ss + 1});
			}
			else{
				if (visited[x][y + i] < 1 + visited[x][y]) break;
			}
		}
		FOR1(i, k) {
			if (y - i <= 0 || pond[x][y - i] == '@') break;
			if (visited[x][y - i] == -1){
				visited[x][y - i] = pt.ss + 1;
				qu.push({{x, y - i}, pt.ss + 1});
			}
			else{
			if (visited[x][y - i] < 1 + visited[x][y]) break;
				
			}
		}
	}

	cout << visited[x2][y2];
	

}

Measured memory_bytes: 13128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int dp[3003][3003][5];
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int r,c;cin>>r>>c;
    int k;cin>>k;
    vv value(r,v(c,0));
    for(int i=0;i<k;i++)
    {
    	int a,b;cin>>a>>b;
    	a--;
    	b--;
    	cin>>value[a][b];
    }
    for(int i=r-1;i>=0;i--)
    {
    	for(int j=c-1;j>=0;j--)
    	{
    		for(int k=0;k<=3;k++)
    		{
    			dp[i][j][k]=max(dp[i+1][j][0],dp[i][j+1][k]);
    			if(k!=3)
    				dp[i][j][k]=max({dp[i+1][j][0]+value[i][j],dp[i][j+1][k+1]+value[i][j],dp[i][j][k]});
    		}
    	}
    }
    cout<<dp[0][0][0]<<endl;
    return 0;
}

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

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

using namespace std;

int main(){
  int w,h,n;
  cin >> w >> h >> n;
  vector<int> x(n),y(n);
  rep(i,n) cin >> x[i] >> y[i];
  int answer = 0;
  rep(i,n-1){
    int mincost = abs(x[i]-x[i+1]) + abs(y[i]-y[i+1]);
    REP(diff,1,10001) {
      int tx = x[i] + diff, ty = y[i] + diff;
      if( !( 0 < tx && tx <= w && 0 < ty && ty <= h ) ) break;
      mincost = min(mincost,abs(tx-x[i+1])+abs(ty-y[i+1])+diff);
    }
    REP(diff,1,10001) {
      int tx = x[i] - diff, ty = y[i] - diff;
      if( !( 0 < tx && tx <= w && 0 < ty && ty <= h ) ) break;
      mincost = min(mincost,abs(tx-x[i+1])+abs(ty-y[i+1])+diff);
    }
    answer += mincost;
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 1200
x = int(input())
if x <= 111:
    print("111")
elif x <= 222:
    print("222")
elif x <= 333:
    print("333")
elif x <= 444:
    print("444")
elif x <= 555:
    print("555")
elif x <= 666:
    print("666")
elif x <= 777:
    print("777")
elif x <= 888:
    print("888")
elif x <= 999:
    print("999")


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

typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n ;
    ll ans=n+1;
    for(ll i=1; i<=sqrt((double) n); i++){
        if(n%i == 0) ans = min(ans, i+n/i);
    }
    cout << ans-2 << endl;
    return 0;
}

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

using namespace std;

inline int getint()
{
	int num=0,flag=1;char c;
	while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
	while(c>='0'&&c<='9')num=num*10+c-48,c=getchar();
	return num*flag;
}

int a,b;

int main()
{
    a=getint(),b=getint()*2;
	printf("%d\n",max(a-b,0));
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include<math.h>
using namespace std;

int main(void)
{
	double a[10] = {};
	double len2, len1;
	double v1, v2;

	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
		&a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6], &a[7], &a[8], &a[9], &v1, &v2) != EOF)
	{
		int len = 0;
		int i;
		int distance;
		len2 = 0;
		len1 = 0;
		int count = 0;
		for (int i = 0; i < 10; i++) len2 += a[i];
		v1 /= 60; v2 /= 60;
		while (len2 >= len1)
		{
			len2 -= v2;
			len1 += v1;
			count++;
		}
		distance = len1 - fabs(len1 - len2);
		//cout << "distance =" << distance << endl;
		for (i = 0; i < 10; i++)
		{
			len += a[i];
		//	cout << "len = " << len << endl;
			if (i == 0)
			{
				if (len > distance && 0 <= distance)
				{
					i++;
					break;
				}
			}
		else if(len - a[i] <= distance && distance < len)
			{
				i++;
				break;
			}
		}
		cout << i << endl;
	}
	return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
const ll mo = 1000000007;
auto mod = [](ll modx) {modx%=mo;modx+=mo;modx%=mo;return modx; };
ll mypow(ll a, ll b)
{
  ll res = 1;
  a %= mo;
  while (b)
  {
    if (b & 1)
      res = res * a % mo;
    a = a * a % mo;
    b >>= 1;
  }
  return res;
}
const ll MAX = 510000;
const ll MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(ll n, ll k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
ll n ;
cin >> n ;
vector<ll> c(n);
ll summ=0;
rep(i, n){
  cin >> c[i];
}
sort(c.begin(),c.end());
vector<ll> v;
v.push_back(1);
rep(i,3*n){
  v.push_back(mod(v[i]*2));
}
vector<ll> sum;
sum.push_back(0);
rep(i,3*n)
{
  sum.push_back(v[i] + sum[i]);
}
COMinit();
rep(i,n){
  ans=mod(ans+mod(v[i]*c[i])*mod(v[n-1-i]+mod(v[n-1-i]*(n-1-i))*mypow(2,mo-2)));
}
ans=mod(ans*v[n]);
cout << ans << endl;
return 0;
}

Measured memory_bytes: 26728
#include<bits/stdc++.h>
typedef long long ll;


using namespace std;
int main()
{
    int n , m , k;
    cin >> n >> m >> k;
    ll a[n + 1] = {0};
    for(int i = 0 ; i < k ; i++){
    	int x;
    	cin >> x;
    	a[0]--;
    	a[x]++;
    	a[x + 1]--;
    }
    for(int i = 1 ; i <= n ; i++){
    	a[i] += (a[i - 1]);
    	// cout << a[i] << " ";
    }
    for(int i = 1 ; i<= n ;i++){
    	if(a[i] + m > 0)
    		cout << "Yes" << endl;
    	else
    		cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<string.h>

int main() {
    int N;
    std::cin >> N;
    int counter = 0;
    bool precount = false;
    for(int i=0;i<N;i++) {
        int a;
        std::cin >> a;
        if( precount ) {
            precount = false;
            continue;
        }
        if(i == a-1) {
            precount = true;
            counter++;
        }
    }
    std::cout << counter << std::endl;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())

if A == 1 and B== 2:
    print(3)
if A == 1 and B== 3:
    print(2)
if A == 2 and B== 1:
    print(3)
if A == 2 and B== 3:
    print(1)
if A == 3 and B== 1:
    print(2)
if A == 3 and B== 2:
    print(1)


Measured memory_bytes: 38256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#define INF 0x3f3f3f3f
#define mod 1000000007
using namespace std;
int a[10000];
int main()
{
	int n,sum=0,b;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		
	}
	sort(a,a+n);
	for(int i=n-1;i>=2;i--)
	{
		for(int j=i-1;j>0;j--)
		{
			for(int k=j-1;k>=0;k--)
			{
				if(a[i]<a[j]+a[k])
				sum++;
			}
		}
	}
	printf("%d\n",sum);
	
}

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

int main() {
  int N;
  cin >> N;
  vector<char> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  bool flag = false;
  for (int i = 0; i < N; i++) {
    if (vec.at(i) == 'Y') {
      flag = true;
    }
  }
  if (flag) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = Integer.parseInt(scanner.nextLine());
        int a = Integer.parseInt(scanner.nextLine());
        int b = Integer.parseInt(scanner.nextLine());
        System.out.println((x - a) % b);
    }
}


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

using namespace std;

int main(){
    char c[2][3];
    for(int i = 0 ; i < 2 ; i++){
        for(int j = 0 ; j < 3 ; j++){
            cin >> c[i][j];
        }
    }
    if(c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	int c[200000];
	
	for(int i = 0; i < a; i++) {
		
		scanf("%d", &c[i]);
	}


	for(int i = b; i < a; i++) {
		if(c[i] > c[i - b]) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}

	return 0;
}


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

int main(){
  int N,M,C,count=0;
  cin >> N >> M >> C;
  vector<int> B(M);
  vector<vector<int>> A(N,vector<int>(M));
  for(int i=0;i<M;i++){
    cin >> B.at(i);
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin >> A.at(i).at(j);
    }
  }
  for(int i=0;i<N;i++){
    int sum=C;
    for(int j=0;j<M;j++){
      sum+=A.at(i).at(j)*B.at(j);
    }
    if(sum>0){
      count++;
    }
  }
  cout << count << endl;
}
  

Measured memory_bytes: 3576
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	long long int n, T;
	cin >> n >> T;
	long long int ans = 0;
	long long int t[200001];
	for(int i = 0; i < n; i++){
		cin >> t[i];
	}
	for(int i = 0; i < n - 1; i++){
		ans += min(t[i + 1] - t[i], T);
	}
	ans += T;
	cout << ans << endl;
	return 0;
}

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

int main() {
    long long N; cin >> N;
    long long mi = 0, ma = 1;
    for (long long p = 2; p * p <= N; ++p) {
        if (N % p != 0) continue;
        int num = 0;
        while (N % p == 0) {
            N /= p;
            ++num;
        }
        ++mi;
        ma *= (num + 1);
    }
    if (N != 1) {
        ++mi;
        ma *= 2;
    }
    cout << mi << " " << ma-1 << endl;
}



Measured memory_bytes: 3112
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = sorted(p)
r = list(itertools.permutations(r, n))
a, b = -1, -1
idx = 0
while True:
    for i in range(n):
        if r[idx][i] != p[i]:
            break
        if i == n - 1:
            a = idx
    for i in range(n):
        if r[idx][i] != q[i]:
            break
        if i == n - 1:
            b = idx
    if a != -1 and b != -1:
        break
    idx += 1
print(abs(a-b))

Measured memory_bytes: 8052
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)

	for sc.Scan() {
		s := strings.Split(sc.Text(), " ")
		m, _ := strconv.Atoi(s[0])
		f, _ := strconv.Atoi(s[1])
		r, _ := strconv.Atoi(s[2])
		if m == -1 && f == -1 && r == -1 {
			return
		}

		if m == -1 || f == -1 {
			fmt.Println("F")
			continue
		}
		if m+f >= 80 {
			fmt.Println("A")
			continue
		}
		if m+f >= 65 {
			fmt.Println("B")
			continue
		}
		if m+f >= 50 {
			fmt.Println("C")
			continue
		}
		if m+f >= 30 {
			if r >= 50 {
				fmt.Println("C")
				continue
			}
			fmt.Println("D")
			continue
		}
		fmt.Println("F")
	}
}



Measured memory_bytes: 1092
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;


#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll ans = 0;
int main() {
	ll n, k;
	cin >> n >> k;
	FOR(i, k, n + 2) ans += i * (n - i + 1) + 1;
	cout << ans % MOD << endl;
}


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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
 
  int min = a + b;
  if(min > b + c){
    min = b + c;
  }
  if(min > a + c){
    min = a + c;
  }
  cout << min << endl;
  
  return 0;
}

Measured memory_bytes: 256
def main():
    N, M = list(map(int, input().split()))
    H = list(map(int, input().split()))
    good = [1] * N

    for i in range(0, M, 1):
        A, B = list(map(int, input().split()))
        if H[A-1] == H[B-1]:
            good[B-1] = 0
            good[A-1] = 0
        elif H[A-1] > H[B-1]:
            good[B-1] = 0
        elif H[A-1] < H[B-1]:
            good[A-1] = 0

    ans = 0
    for i in range(0, N, 1):
        if good[i] == 1:
            ans = ans+1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20072
#include<stdio.h>
#include<iostream>

using namespace std;

#define BUF_SIZE 1024

class Stack{
public:
	Stack(int stack_size):
		m_index(0){
		m_array = new int[stack_size];
	};
	~Stack(){
		delete[] m_array;
	};
	void push(int var){
		m_array[m_index++] = var;
	};
	int pop(){
		return m_array[--m_index];
	};

	bool isEmpty(){
		return m_index == 0;
	};

private:
	int* m_array;
	int m_index;
};

int main(){
	char buf[BUF_SIZE];

	for(int i = 0; i < BUF_SIZE; i++){
		buf[i] = 'e';
	}
	fgets(buf,BUF_SIZE,stdin);

	Stack stack(BUF_SIZE);

	bool numFLG = false;
	int S = 0,op1=0,op2=0;

	for(int i = 0;buf[i] != 'e'; i++){
		if(buf[i] >= '0' && buf[i] <= '9'){
			numFLG = true;
			S = 10*S + (buf[i] - '0');
		}else{
			if(numFLG){
				stack.push(S);
				S = 0;
				numFLG = false;
			}

			if(buf[i] == '+'){
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1+op2);
			}else if(buf[i] == '-'){
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1-op2);
			}else if(buf[i] == '*'){
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1*op2);
			}
		}
	}

	op1 = stack.pop();
	printf("%d\n",op1);
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;

//-----------------------------------------------------------------------------

string s;
int a,b,c;

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

	cin>>s;
	REP(i,s.size()) (s[i]=='a'?a:s[i]=='b'?b:c)+=1;

	if(abs(a-b)>=2||abs(b-c)>=2||abs(a-c)>=2) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1){r=(r*a)%m;}
        b=b>>1;
        a=(a*a)%m;
    }
    return r%m;
}
int main(){
    ll n,k; cin>>n>>k;
    vi arr(n);
    rep(i,0,n)cin>>arr[i];
    vi dp(n,INT_MAX);
    dp[0] = 0;
    dp[1] = fabs(arr[1]-arr[0]);
    for(ll i=2;i<n;i++)
    {
        for(ll j = 1;j<=k&&i>=j;j++)
        {
            ll x= fabs(arr[i]-arr[i-j]);
            dp[i] = min(dp[i], dp[i-j]+x);
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1792
// AOJ Volume 0 Problem 0085

#include <stdio.h>
#include <string.h>

int main(void)
{
    int n, m;
	int i, j;
    int pos;
	int step;
	int flag[1001];
    
    while (1){
		scanf("%d%d", &n, &m);
		if (n == 0 && m == 0){
			break;
		}
		
		memset(flag, 0, sizeof(flag));
		pos = n - 1;
		for (i = 0; i < n - 1; i++){
			step = 0;
			while (step < m){
				pos++;
				pos %= n;
				if (flag[pos] == 0){
					step++;
				}
			}
//			printf("<%d>", pos + 1);

			flag[pos] = 1;
		}
		for (i = 0; flag[i] != 0; i++);
		printf("%d\n", i + 1);
    }
    
    return (0);
}

Measured memory_bytes: 412
N = int(input())
#N = 100000
#S = [input() for i in range(N)]
S = [input() for i in range(N)]
#S = ['zabcdefghi']*100000

#groups = {i: [] for i in range(26)}
sort_str = {}

counter = 0
for i in range(N):
    s = ''.join(sorted(S[i]))
    if s in sort_str:
        counter += sort_str[s]
        sort_str[s] += 1 
    else:
        sort_str[s] = 1
print(counter)
#
#
#    groups[int(s[0], 36) - 10].append(s)
#
#counter = 0
#for group in groups.values():
#    for i in range(len(group)):
#        for j in range(i+1, len(group)):
#            print(i, j)
#            if group[i] == group[j]:
#                counter += 1
#
#print(counter)
#
#


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

int main() {
    string S;
    cin >> S;
    int num=0;

    for(char c='a';c<='c';c++){
        for(int i=0;i<3;i++){
            if(S[i]==c) {
                num++;
                break;
            }
                
        }
    }
    if(num==3) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256