akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();    
        int[] a = r.ii();
        println((a[0]*3+a[1])/2);
    }

    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}


Measured memory_bytes: 21332
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
using namespace std;
typedef long long ll;
int n;
ll x[100001],y[100001];
ll px[200001],py[200001];
bool pz[200001];
ll tae(ll x,ll y,int id){//y<2^59
	if(x==px[id] && y==py[id]) return pz[id];
	bool eq=1,sm=0;
	for(int i=58; i>=0 ;i--){
		if(eq==0 && sm==0) break;
		if((x&(1LL<<i))){
			if((y&(1LL<<i))) sm=eq;
			else{sm^=eq;eq=0;}
		}
		else{
			if((y&(1LL<<i))) sm=0;
		}
	}
	px[id]=x,py[id]=y,pz[id]=(eq^sm);
	return eq^sm;
}
int qry(ll l,ll r){
	int sum=0;
	for(int i=1; i<=n ;i++){
		ll ty=y[i]+(1LL<<58);
		ll xl=max(0LL,l-x[i]);
		ll xr=min(ty,r-x[i]);
		if(xl>xr) continue;
		sum^=tae(xr,ty,i*2-1)%2;
		if(xl!=x[i]) sum^=tae(xl-1,ty,i*2);
	}
	return sum;
}
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=1; i<=n ;i++){
		cin >> x[i] >> y[i];
	}
	ll l=-1.232323e17,r=1.0669e17;
	while(l!=r){
		ll mid=l+(r-l)/2;
		int sum=qry(l,mid);
		if(sum%2==0) l=mid+1;
		else r=mid;
	}
	cout << l << endl;
}

Measured memory_bytes: 5120
#include<iostream>
#include<string>
#include<cstdlib>
#include<math.h>
using namespace std;
int main(void){
    string str;
    cin >> str;
    if(str.size()==2){
        printf("%c%c",str[0],str[1]);
    }else{
        printf("%c%c%c",str[2],str[1],str[0]);
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int a[3], cnt = 0;
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
		for (int j = 0; j < i; j++) {
			if (a[j] != a[i])cnt++;
		}
	}
	if (cnt == 0)cnt++;
	cout << cnt << endl;
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<long long> A(N);
	long long XOR = 0;
	for (int i = 0; i < N; i++) cin >> A[i], XOR ^= A[i];
	for (int i = 0; i < N; i++) cout << (XOR ^ A[i]) << (i == N - 1 ? '\n' : ' ');
}

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

using ll = long long;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> r(a), g(b), none(c);
	for(int& z : r) cin >> z;
	for(int& z : g) cin >> z;
	for(int& z : none) cin >> z;
	sort(r.rbegin(), r.rend());
	sort(g.rbegin(), g.rend());
	sort(none.rbegin(), none.rend());
	priority_queue<int, vector<int>, greater<int>> red, green;
	for(int i = 0; i < x; i++) {
		red.push(r[i]);
	}
	for(int i = 0; i < y; i++) {
		green.push(g[i]);
	}
	
	for(int i = 0; i < c; i++) {
		int left = none[i] - red.top();
		int right = none[i] - green.top();
		if(max(left, right) <= 0) {
			break;
		} else if(left > right) {
			red.pop();
			red.push(none[i]);
		} else {
			green.pop();
			green.push(none[i]);
		}
	}
	
	ll ans = 0;
	while(red.size()) {
		ans += red.top();
		red.pop();
	}
	while(green.size()) {
		ans += green.top();
		green.pop();
	}
	
	
	cout << ans << endl;
}


Measured memory_bytes: 2552
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


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


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    dp = [0] * (N + 1)
    for i in range(N):
        dp[i + 1] = dp[i] + A[i]

    m = defaultdict(int)
    for v in dp:
        m[v % M] += 1

    ans = 0
    for v in dp:
        m[v % M] -= 1
        ans += m[v % M]

    print(ans)


if __name__ == '__main__':
    main()


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n), sm(n+1);

	rep(i,n) cin >>a[i];
	rep(i,n) sm[i+1] = sm[i] + a[i];
	//for(auto x :sm) printf("%lld, ",x); puts("");
	ll ans = 1LL<<58;
	rep2(i,1, n-2){
		ll sml = sm[i+1];
		ll smr = sm[n] - sm[i+1];
		//cout <<sml <<" "<<smr <<"\n";
	
		ll tg1=sml/2;
		int ps1 = lower_bound(all(sm), tg1) - sm.begin();
		//ps1 = max(0, min(ps1, i-1));
		ll tg2=smr/2;
		int ps2 = lower_bound(all(sm), tg2+sm[i+1]) - sm.begin();
		//ps2 = max(i+1, min(ps2, n));
		
		rep2(ql, ps1-2, ps1+3) rep2(qr, ps2-2, ps2+3){ 
			if(ql <0 || ql >=i) continue;
			if(qr <i || qr >=n-1) continue;
			ll wmn=1LL<<61, wmx=0;
			wmn = min({sm[ql+1], sm[i+1]-sm[ql+1], 
				sm[qr+1]-sm[i+1], sm[n]-sm[qr+1]});
			wmx = max({sm[ql+1], sm[i+1]-sm[ql+1],
				sm[qr+1]-sm[i+1], sm[n]-sm[qr+1]});
			//printf("%d:%d:%d:%lld:%lld \n", ql, i, qr,wmn, wmx);
			ans = min(ans, wmx - wmn);
		}
	}
	
	
	cout << ans <<"\n";
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define INF 1000000000
#define MOD 1000000007
using ll = long long;

int main(){
  int n;
  cin >> n;
  vector<int> x(n),y(n),H(n);
  rep(i,n)cin >> x.at(i) >> y.at(i) >> H.at(i);
  rep(cx,101){
    rep(cy,101){
      vector<int> absdif(n);
      int h = 0;
      int flag = 1;
      rep(i,n){
        absdif.at(i)=abs(x.at(i)-cx)+abs(y.at(i)-cy);
        if(H.at(i)!=0&&h==0){
          h=H.at(i)+absdif.at(i);
          break;
        }
      }
      rep(i,n){
        absdif.at(i)=abs(x.at(i)-cx)+abs(y.at(i)-cy);
        if(H.at(i)!=max(0,h-absdif.at(i))){
          flag=0;
          break;
        }
      }
      if(flag)cout<<cx<<" "<<cy<<" "<<h<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
# abc138 D ki

import sys
sys.setrecursionlimit(10**6)

# def input():
#     return sys.stdin.readline()[:-1]

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

point=[0]*N

for _ in range(N-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
    
for _ in range(Q):
    a,b=map(int,input().split())
    a-=1
    point[a]+=b

def dfs(n,pre=-1):
    for ne in g[n]:
        if ne == pre:
            continue
        
        point[ne]+=point[n]
        
        dfs(ne,n)
        
dfs(0)
print(*point)

Measured memory_bytes: 282992
import sys
from collections import deque

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, m = nm()
    friends = [set() for _ in range(n)]
    for i in range(m):
        a, b = nm()
        friends[a - 1].add(b - 1)
        friends[b - 1].add(a - 1)

    groups = []
    in_group = [False] * n
    for i in range(n):
        if in_group[i]:
            continue
        d = deque(friends[i])
        group = [i]
        in_group[i] = True
        while d:
            c = d.pop()
            if in_group[c]:
                continue
            group.append(c)
            in_group[c] = True
            for friend in friends[c]:
                if not in_group[friend]:
                    d.append(friend)
        groups.append(group)

    ans = 0
    for group in groups:
        ans = max(ans, len(group))
    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
    int a,b;
    cin>>a>>b;
    if(a%3==0||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
    return 0;
}

Measured memory_bytes: 3576
#include<stdio.h>

int main(void) {
  int n, a[20], max = 0, cnt = 0;
	scanf("%d", &n);

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

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

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

	return 0;
}


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

int main()
{
	int n;
	cin >> n;
	map<string,int> m;

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

	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;
}







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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

const int MAX_V = 110000;
const int INF = 1e14;

struct edge {
    int to, cap, rev;
};

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap) {
    G[from].push_back((edge) {to, cap, G[to].size()});
    G[to].push_back((edge) {from, 0, G[from].size() - 1});
}

int dfs(int v, int t, int f) {
    if (v == t) {
        return f;
    }
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t) {
    int flow = 0;
    for (;; ) {
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if (f == 0) {
            return flow;
        }
        flow += f;
    }
}

int N;
int a[110];

signed main() {
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> a[i];

    for (int i = 1; i <= N; i++) {
        add_edge(0, i, INF - a[i]);
        add_edge(i, 101, INF);
        for (int j = 2 * i; j <= N; j += i) add_edge(i, j, INF);
    }
    cout << INF*N - max_flow(0, 101);

}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define ll long long
#define db double
using namespace std;
const int M=1e6+10;
bool vis[M];
int in[M];
int a[M],n;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]),in[a[i]]++;
    bool flag=1;
    for(int i=2;i<M;i++)
        if(!vis[i])
        {
            int cnt=0;
            for(int j=i;j<M;j+=i)
                vis[j]=1,cnt+=in[j];
            if(cnt>1)
            {
                flag=0;
                break;
            }
        }
    if(flag) return puts("pairwise coprime"),0;
    int g=a[0];
    for(int i=1;i<n;i++)
        g=__gcd(g,a[i]);
    if(g==1) return puts("setwise coprime"),0;
    puts("not coprime");
    return 0;
}


Measured memory_bytes: 12432
def main():
    S = int(input())
    if S == pow(10, 18):
        return 0, 0, pow(10, 9), 0, 0, pow(10, 9)
    x1, y1 = 0, 0
    x2, y2 = pow(10, 9), 1
    y3 = S // pow(10, 9) + 1
    x3 = pow(10, 9) - S % pow(10, 9)
    # S = ad-bc
    # S = 10^9 d - c = 10^9(d-1) + (10^9-c)
    return x1, y1, x2, y2, x3, y3


if __name__ == '__main__':
    output = main()
    print(" ".join(map(str, output)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K,c;
  long res=0;
  cin>>N>>K;
  vector<int> a(N,0);
  for(int i=0;i<N;++i){
    cin>>a[i];
    if(a[i]>K)res+=a[i]-K,a[i]=K;
  }
  for(int i=1;i<N;++i){
    c=(a[i]+a[i-1]>K?a[i]+a[i-1]-K:0);
    if(c)res+=c,a[i]-=c;
  }
  cout<<res;
  return 0;
}
  

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

"""
参考：http://hamko.hatenadiary.jp/entry/2018/01/30/210057
　　　http://at274.hatenablog.com/entry/2018/02/03/140504
・重み付きUnion-Find木
"""

import sys
def input(): return sys.stdin.readline().strip()

class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = - w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

N, M = map(int, input().split())

wuf = WeightedUnionFind(N)
for i in range(M):
    x, y, w = map(int, input().split())
    # 同じ集合に属する場合
    if wuf.same(x, y):
        # 記録された距離と今回の情報に矛盾がないか確認
        if wuf.diff(x, y) != w:
            print('No')
            exit()
    wuf.union(x, y, w)
# 全部無矛盾で木が構築できればOK
print('Yes')


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

#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double

using namespace std;

const int mod = (int)1e9 + 7;
int n;
string s1, s2;
int a[3][100];
ll dp[100][3];

int main() {

	cin >> n >> s1 >> s2;
	for(int i = 0; i < s1.sz; i++) a[1][i+1] = s1[i] - 'a';
	for(int i = 0; i < s2.sz; i++) a[2][i+1] = s2[i] - 'a';
	

	int start = 3;
	dp[0][1] = dp[0][2] = 1;

	if(a[1][1] == a[2][1]) {
		dp[1][1] = 3;
		start = 2;
	} else {
		dp[2][2] = 6;
	}

	for(int i = start; i <= n; i++) {
		if(a[1][i] == a[2][i]) {
			//vertical
			dp[i][1] += dp[i-1][1] * 1ll * 2;
			dp[i][1] %= mod;
			dp[i][1] += dp[i-1][2];
			dp[i][1] %= mod;
		} else {
			//horizontal
			if(a[1][i] == a[1][i-1]) {
				//second
				dp[i][2] = dp[i-1][2];
				dp[i][2] %= mod;	
			} else {
				//first
				dp[i][2] += dp[i-1][2] * 1ll * 3;
				dp[i][2] %= mod;
				dp[i][2] += dp[i-1][1] * 1ll * 2;
				dp[i][2] %= mod;
			}
		}

		dp[i][1] %= mod;
		dp[i][2] %= mod;
	}

	cout << (dp[n][1] + dp[n][2]) % mod << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
using namespace std;
int main()
{
	int a;
	int b;
	int k;
	cin >> a >> b >> k;
	if (2 * k > b - a){
		for (int t = a; t < b + 1; t++){
			cout << t << endl;
		}
	}
	else{
		for (int t = a; t < a + k; t++){
			cout << t << endl;
		}
		for (int t = b-k+1; t < b+1; t++){
			cout << t << endl;
		}
	}
}

Measured memory_bytes: 256
#![allow(bare_trait_objects)]
#![allow(unused_imports)]
#![allow(dead_code)]

use std::fmt::Debug;
use std::io::BufRead;
use std::io::Stdin;
use std::io::StdinLock;
use std::str::FromStr;

pub struct Scanner<'a> {
    // stdin: Stdin,
    buf_read: Box<BufRead + 'a>,
    tokens: Vec<String>,
}

impl<'a> Scanner<'a> {
    pub fn new(buf_read: StdinLock<'a>) -> Self {
        Scanner {
            buf_read: Box::new(buf_read),
            tokens: Vec::new(),
        }
    }

    // pub fn from_stdin() -> Self {
    //     let stdin = Box::leak(Box::new(std::io::stdin()));
    //     Self {
    //         buf_read: Box::new(stdin.lock()),
    //         tokens: Vec::new(),
    //     }
    // }

    pub fn next(&mut self) -> String {
        while self.tokens.is_empty() {
            let mut s = String::new();
            if self.buf_read.read_line(&mut s).is_err() {
                panic!()
            }
            self.tokens = s
                .split_whitespace()
                .filter(|s| !s.is_empty())
                .rev()
                .map(str::to_string)
                .collect();
        }
        self.tokens.pop().unwrap()
    }

    pub fn next_g<T: FromStr>(&mut self) -> T
    where
        T::Err: Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn next_vec_g<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: Debug,
    {
        (0..n).map(|_| self.next_g()).collect()
    }

    pub fn usize(&mut self) -> usize {
        self.next_g()
    }

    pub fn i64(&mut self) -> i64 {
        self.next_g()
    }

    pub fn vec_i64(&mut self, n: usize) -> Vec<i64> {
        self.next_vec_g(n)
    }
}

fn dfs(n: usize, m: usize, s: String) {
    if n == 0 {
        println!("{}", s);
        return;
    }
    for i in 0..m + 1 {
        dfs(
            n - 1,
            std::cmp::max(i + 1, m),
            s.clone() + &(('a' as u8 + i as u8) as char).to_string(),
        );
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let n = sc.usize();

    dfs(n, 0, "".to_string());
}


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


int main() {

  int64_t n,a,b;
  cin>>n>>a>>b;

  if(a>b)
    cout<<0<<endl;
  else if(a!=b&&n==1)
    cout<<0<<endl;
  else if(a==b)
    cout<<1<<endl;
  else{
    cout<<(b-a)*(n-2)+1<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{
	string n;
	cin>>n;
	if((n[0]==n[1]&&n[1]==n[2])||(n[1]==n[2]&&n[2]==n[3]))
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
map<LL, LL> cnt;
const int maxn = 2e5 + 10;
LL a[maxn], sum[maxn];

int main(){
    int N;
    LL ans = 0;
    scanf("%d", &N);
    cnt[0]++;
    for(int i = 1; i <= N; ++i){
        scanf("%lld", a + i), sum[i] = sum[i-1] + a[i];
        ans += cnt[sum[i]];
        cnt[sum[i]]++;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i,a,b) for(register int i=(a);i<(b);i++)
#define per(i,a,b) for(register int i=(b);i>=(a);i--)
#define For(i,a,b) for(register int i=(a);i<=(b);i++)
#define Forenska(it,c) for(register __typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
using namespace std;
typedef long long LL;
typedef pair<int,int> Pair;
typedef vector<int> vec;
const long double PI=3.14159265358979323846264338327950288;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const int MAX_N=100005;
int used[MAX_N];
int L[MAX_N];
int R[MAX_N];
int known[MAX_N][2];
int know[MAX_N];
bool res=true;
vec g[MAX_N],order;
int l[MAX_N];
int r[MAX_N];
bool shit;
int n;
int par[MAX_N];
int val[MAX_N];
void dfs(int v)
{
	used[v]=1;
	l[v]=-INF;
	r[v]=INF;
	rep(i,0,g[v].size())
	{
		int to=g[v][i];
		if(used[to])continue;
		dfs(to);
		par[to]=v;
		if(known[to][0])
		{
			known[v][1]=1;
		}
		if(known[to][1])
		{
			known[v][0]=1;
		}
		l[v]=max(l[v],l[to]-1);
		r[v]=min(r[v],r[to]+1);
	}
	if(know[v]==1)
	{
		l[v]=max(l[v],val[v]);
		r[v]=min(r[v],val[v]);
		known[v][val[v]%2]=1;
	}
	if(known[v][0]==1 && known[v][1]==1 || l[v]>r[v])
	{
		shit=true;
	}
	order.pb(v);
}
int ans[MAX_N];
int solve_val(int v,int par)
{
	if(par==0)
	{
		return l[v];
	}
	l[v]=max(l[v],ans[par]-1);
	r[v]=min(r[v],ans[par]+1);
	while(l[v]%2==ans[par]%2)l[v]++;
	return l[v];
}
int main()
{
	cin>>n;
	rep(i,1,n)
	{
		int a,b;
		cin>>a>>b;
		g[a].pb(b);
		g[b].pb(a);
	}
	int K;
	cin>>K;
	rep(i,0,K)
	{
		int v,p;
		cin>>v>>p;
		know[v]=1;
		val[v]=p;
	}
	dfs(1);
	if(shit)
	{
		cout<<"No"<<endl;
		return 0;
	}
	reverse(all(order));
	cout<<"Yes"<<endl;
	rep(i,0,order.size())
	{
		int v=order[i];
		ans[v]=solve_val(v,par[v]);
	}
	For(i,1,n)cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 15736
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.nextLine());
        int[] a = new int[n];
        for(int i=0; i<n; i++){
            a[i] = Integer.parseInt(scan.nextLine());
        }
        
        int[] max = new int[n-1];
        int[] min = new int[n-1];
        int[] dif = new int[n-1];

        for(int i=0; i<n-1; i++){
            if(i==0){min[0]=a[0];}
            else{min[i] = Math.min(min[i-1], a[i]);}
        }    
        
        for(int i=n-2; i>=0; i--){
            if(i==n-2){max[n-2]=a[n-1];}
            else{max[i] = Math.max(max[i+1], a[i+1]);}  
        }   
        
        for(int i=0; i<n-1; i++){
            dif[i] = max[i]-min[i];  
        }
        
        int maximum = -1000000000;
        
        for(int i=0; i<n-1; i++){
            maximum = Math.max(maximum, dif[i]);
        }
        
        System.out.println(maximum);
    }
    
}

Measured memory_bytes: 167584
n,m = map(int,input().split())
road = [0] * n
for i in range(m):
	a,b = map(int,input().split())
	road[a-1] = road[a-1] + 1
	road[b-1] = road[b-1] + 1

for i in range(n):
	print(road[i])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<sqrt(n);i++)
    {
        if(n%i==0)
        {
          c++;
        }
    }
    c=c*2;
    if(pow(sqrt(n),2)==(sqrt(n)*sqrt(n)))
        c++;
    return  c;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   int n,k;
   cin>>n>>k;
   int time=INT_MAX;
   while(n--)
   {
         int a,b;
         cin>>a>>b;
         if(b<=k)
         {
            time=min(time,a);
         }
   }  
   if(time==INT_MAX)
    cout<<"TLE";
else cout<<time;

 return 0;
}








Measured memory_bytes: 3420
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    int no_of_stones;
    cin >> no_of_stones;

    vector <int> height(no_of_stones + 1, 0);
    for(int i = 1; i <= no_of_stones; i++)
        cin >> height[i];

    vector <int> minimum_cost(no_of_stones + 1);
    minimum_cost[2] = abs(height[2] - height[1]);
    for(int i = 3; i <= no_of_stones; i++)
        minimum_cost[i] = min(minimum_cost[i - 1] + abs(height[i] - height[i - 1]),
                              minimum_cost[i - 2] + abs(height[i] - height[i - 2]));

    cout << minimum_cost[no_of_stones];
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
t0, x0, y0 = 0, 0, 0

for i in range(n):
  ti, xi, yi = map(int, input().split())
  test = (ti - t0) - (xi + yi - x0 - y0)
  
  if test >= 0 and test % 2 == 0:
    t0, x0, y0 = ti, xi, yi
    if i == n-1:
      print("Yes")
  else:
    print("No")
    break

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	List<bool> s;
	public K()
	{
		ReadLine();
		s = (ReadLine() + "00").Select(x => x == '1').ToList();
		int N = s.Count, l = 0, ans = 0;
		// split s by 00
		while (true)
		{
			while (l < N && !s[l]) l++;
			if (l >= N) break;
			var r = l + 1;
			while (s[r] || s[r + 1]) r++;
			ans += Solve(l, r);
			l = r;
		}
		WriteLine(ans);
	}
	// 110101110111101 => 201030401 => 2,1,3,4,1
	int Solve(int l, int r)
	{
		var x = new List<int>{ 0 };
		var i = 0;
		while (l < r)
			if (s[l++]) x[i]++;
			else { x.Add(0); i++; }
		return DP(x, x.Count);
	}
	// a 0 b (11011111 = 2 0 5) =>
	// (0)  a  0  1
	// (1) a-1 0  1
	// (2)  1  0  b
	// (3)  1  0 b-1
	// (4)  1  0  1
	// (5)  0  0  0
	static int L(int i, int a) => i == 0 ? a : i == 1 ? a - 1 : i == 5 ? 0 : 1;
	static int R(int i, int a) => i == 2 ? a : i == 3 ? a - 1 : i == 5 ? 0 : 1;
	static int M(int i, int a, int b) => Max(L(i, a), R(i, b));
	static bool P(int i, int a, int b)
	{
		switch (i)
		{
		case 0: return a > 1;
		case 1: return a > 2;
		case 2: return b > 1;
		case 3: return b > 2;
		default: return true;
		}
	}
	static int DP(List<int> x, int n)
	{
		if (n <= 1) return 0;
		var dp = new int[n - 1, 6];
		for (var i = 0; i < 6; i++) if (P(i, x[0], x[1])) dp[0, i] = M(i, x[0], x[1]);
		for (var i = 1; i < n - 1; i++)
			for (var j = 0; j < 6; j++)
				for (var k = 0; k < 6; k++)
					if (P(j, x[i - 1], x[i]) && P(k, x[i], x[i + 1]) && R(j, x[i]) + L(k, x[i]) <= x[i])
						dp[i, k] = Max(dp[i, k], dp[i - 1, j] + M(k, x[i], x[i + 1]));
		var m = 0;
		for (var i = 0; i < 6; i++) m = Max(m, dp[n - 2, i]);
		return m;
	}
}


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

int main() {
    int x, y;
    cin >> x >> y;
    int ans = 0;

    if (x == 1) {
        ans += 300000;
    }
    else if (x == 2) {
        ans += 200000;
    }
    else if (x == 3) {
        ans += 100000;
    }

    if (y == 1) {
        ans += 300000;
    }
    else if (y == 2) {
        ans += 200000;
    }
    else if (y == 3) {
        ans += 100000;
    }

    if (x == 1 && y == 1) {
        ans += 400000;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
s=input()
numbers=[]
[numbers.append(int(s[i])) for i in range(4)]
for i in range(2**3):
  opes=[]
  count=numbers[0]
  for j in range(3):
    if (i>>j)&1:
      opes.append("+")
      count+=numbers[j+1]
    else:
      opes.append("-")
      count-=numbers[j+1]
  if count==7:
    print(numbers[0],end="")
    for k in range(3):
      print(opes[k],end="")
      print(numbers[k+1],end="")
    print("=",end="")
    print(count)
    exit()

Measured memory_bytes: 9172
#  --*-coding:utf-8-*--



def main():
    N, D = map(int, input().split())
    X = [tuple(map(int, input().split())) for _ in range(N)]
    c = 0
    
    for i, x1 in enumerate(X):
        for x2 in X[i+1:]:
            d = sum((x1[j] - x2[j])**2 for j in range(D))
            if round(d**.5)**2 == d:
                c += 1

    print(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b;
  for(c=1;c<=3;c++)
  {
    if(a*b*c%2!=0)
    {
      cout<<"Yes"<<endl;
      return 0;
    }
  }
cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

#include <iostream>
using i64 = long long;
template<i64 M> struct modint { i64 a;
  constexpr modint(const i64 x = 0): a((x%M+M)%M){}
  constexpr i64 value() const { return a; }
  constexpr modint inv() const { return this->pow(M-2); }
  constexpr modint pow(i64 r) const {
    modint ans(1); modint aa = *this;
    while(r) { if(r & 1) ans *= aa; aa *= aa; r >>= 1; }
    return ans;
  }
  constexpr modint& operator=(const i64 r) { a = (r % M + M) % M; return *this; }
  constexpr modint& operator+=(const modint r) { a += r.a; if(a >= M) a -= M; return *this; }
  constexpr modint& operator-=(const modint r) { a -= r.a; if(a < 0) a += M; return *this; }
  constexpr modint& operator*=(const modint r) { a = a * r.a % M; return *this; }
  constexpr modint& operator/=(const modint r) { (*this) *= r.inv(); return *this; }
  constexpr modint operator+(const modint r) const { return modint(*this) += r; }
  constexpr modint operator-(const modint r) const { return modint(*this) -= r; }
  constexpr modint operator*(const modint r) const { return modint(*this) *= r; }
  constexpr modint operator/(const modint r) const { return modint(*this) /= r; }
  constexpr bool operator!=(const modint r) const { return this->value() != r.value(); }
};

template<const i64 M> std::ostream& operator<<(std::ostream& os, const modint<M>& m) { os << m.value(); return os; }

using fp = modint<998244353>;

int main() {
  i64 N;
  cin >> N;
  string S;
  cin >> S;
  vector<i64> now(8);
  fp ans(1);
  rep(i,0,N * 3) {
    i64 k = 0;
    if(S[i] == 'R') k = 1;
    if(S[i] == 'G') k = 2;
    if(S[i] == 'B') k = 4;
    bool OK = true;
    if(OK) {
      if(now[0b111 ^ k]) {
        ans *= fp(now[0b111 ^ k]);
        now[0b111 ^ k]--;
        OK = false;
      }
    }
    if(OK) {
      for(int l = 1; l < 8; l <<= 1) {
        if(l == k) continue;
        if(now[l] == 0) continue;
        ans *= fp(now[l]);
        now[l ^ k]++;
        now[l]--;
        OK = false;
        break;
      }
    }
    if(OK) {
      now[k]++;
    }
  }
  rep(i,1,N + 1) {
    ans *= fp(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
pair<int, string> parse(string s, int st) {
  string res = "";
  int cnt = 0;
  for(int i=st;i<(int)(s.size());++i) {
    if(s[i] == '[') {
      pair<int, string> tmp = parse(s, i+1);
      i = tmp.first;
      res += tmp.second;
    } else if(s[i] == '+') {
      cnt++;
    } else if(s[i] == '-') {
      cnt--;
    } else if(s[i] == ']') {
      reverse(res.begin(), res.end());
      return {i, res};
    } else if(s[i] == '?') {
      res.push_back('A');
      cnt = 0;
    } else {
      res.push_back((s[i] - 'A' + cnt + 26 * 4) % 26 + 'A');
      cnt = 0;
    }
  }
  return {(int)(s.size()), res};
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    string s; cin >> s;
    if(s == ".") break;
    cout << parse(s, 0).second << endl;
  }
}



Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll n; cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }

    vector<vector<int>> alphs(n, vector<int>(26, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < s[i].size(); ++j) {
            alphs[i][s[i][j] - 'a'] += 1;
        }
    }
    // for (auto i: alphs) {
    //     for (auto j: i) {
    //         cout << j;
    //     }
    //     cout << endl;
    // }

    vector<int> common(26, n);
    for (int i = 0; i < 26; ++i) {
        common[i] = alphs[0][i];
    }
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < 26; ++j) {
            common[j] = min(common[j], alphs[i][j]);
        }
    }

    // for (auto i: common) {
    //     cout << i;
    // }
    // cout << endl;
    
    for (int i = 0; i < 26; ++i) {
        for (int j = 0; j < common[i]; ++j) {
            cout << (char)('a' + i);
        }
    }
    cout << endl;
}

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

int main(){
  char s;
  cin >> s;
  int x = 100;
  if(s=='a') x = 0;
    if(s=='b') x = 1;
    if(s=='c') x = 2;
    if(s=='d') x = 3;
    if(s=='e') x = 4;
    if(s=='f') x = 5;
    if(s=='g') x = 6;
    if(s=='h') x = 7;
    if(s=='i') x = 8;
    if(s=='j') x = 9;
    if(s=='k') x = 10;
    if(s=='l') x =11;
    if(s=='m') x =12;
    if(s=='n') x =13;
    if(s=='o') x =14;
    if(s=='p') x =15;
    if(s=='q') x =16;
    if(s=='r') x =17;
    if(s=='s') x =18;
    if(s=='t') x =19;
    if(s=='u') x =20;
    if(s=='v') x =21;
    if(s=='w') x =22;
    if(s=='x') x =23;
    if(s=='y') x =24;
    if(s=='z') x =25;
  

  
  if(x ==100){
  cout <<'A' << endl;
  }
  else{
    cout <<'a' << endl;
  }
}



Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	double ans = 0;

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

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int A = 0, B = 1;
			if (A == i) {
				if (A + 1 != j)A = A + 1;
				else A = A + 2;
			}
			if (B == j) {
				if (B + 1 != A)B = B + 1;
				else B = B + 2;
			}
			ans = max(ans,((double)a[A]+a[B])/(a[i]-a[j]));
		}
	}
	printf("%.10f\n",ans);
	return	0;
}

Measured memory_bytes: 3280
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int a[3];
  REP(i,3)cin>>a[i];
  sort(a,a+3);
  cout<<a[0]+a[1]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int par[500010]; 
int depth[500010]; 
int sz[500010];
string S, T; 
void init(){
	for(int i = 0; i < S.size(); i++){
		par[i] = i; depth[i] = 0; sz[i] = 1; 
	}
}
int find(int x){
	if(par[x] == x){
		return x;
	}
	else{
		return par[x] = find(par[x]); 
	}
}
void unite(int x, int y){
	x = find(x); 
	y = find(y); 
	if(x == y) return;
	else if(depth[x] < depth[y]){
		par[x] = y; 
		sz[y] += sz[x]; 
	}else{
		par[y] = x; 
		sz[x] += sz[y];  
		if(depth[x] == depth[y]) depth[x] ++; 
	}
}
bool same(int x, int y){
	return find(x) == find(y); 
}
int siz(int x){
	return sz[find(x)]; 
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	cin >> S >> T; init(); 
	string U = T + "*" + S; 
	while(1){
		if(U.size() > S.size() + T.size() * 2) break; 
		U += S; 	
	}
	int Z[2000010] = {}; 
	Z[0] = T.size(); 
	int i = 1, j = 0; 
	while(i < U.size()){
		while(i + j < U.size() && U[j] == U[i + j]) j++;
		Z[i] = j;
		if(j == 0){
			i++; continue;
		}
		int k = 1;
		while(k < j && k + Z[k] < j){
			Z[i + k] = Z[k]; k++;
		}
		i += k; j -= k;
	}
	for(int i = 0; i < S.size(); i++){
		if(Z[T.size() + 1 + i] != T.size()) continue; 
		int k = (i + T.size()) % S.size(); 
		if(same(i, k)){
			cout << -1 << endl; return 0; 
		}
		unite(i, k); 
	}
	int ans = 0; 
	for(int i = 0; i < S.size(); i++){
		ans = max(ans, siz(i)); 
	}
	cout << ans - 1 << endl;
}

Measured memory_bytes: 17352
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=600000 +117;
const int MM=500000 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
LL dp[2][NN]={};
LL fact[NN]={};
LL rev[NN]={};
LL mi[2][NN]={};
const int mod=998244353;
LL ksm(LL a,LL b){
	LL ret=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ret=ret*a%mod;
	return ret;
}
LL getfact(int n){
	fact[0]=1;
	for(int i=1;i<=n;++i)fact[i]=fact[i-1]*i%mod;
	rev[n]=ksm(fact[n],mod-2);
	for(int i=n;i>=1;--i)rev[i-1]=rev[i]*i%mod;
}
LL comp(int n,int m){
	return fact[n]*rev[m]%mod*rev[n-m]%mod;
}
int main(){
	//open();
	n=read();
	m=read();
	getfact(max(n,m));
	int sym=1;
	LL ans=0;
	mi[0][0]=mi[1][0]=1;
	for(int i=1;i<=max(n,m);++i){
		mi[0][i]=mi[0][i-1]*(n+1)%mod;
		mi[1][i]=mi[1][i-1]*(m+1)%mod;
	}
	for(int i=0;i<=min(n,m);++i){
		ans+=sym*comp(n,i)*comp(m,i)%mod*fact[i]%mod*mi[0][m-i]%mod*mi[1][n-i]%mod;
		ans%=mod;
		sym=-sym;
	}
	ans=(ans+mod)%mod;
	printf("%lld\n",ans);

	close();
	return 0;
}

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

Measured memory_bytes: 3064
#include <cstdio>
#include <numeric>
#include <cmath>

using namespace std;

static int gcd(int a, int b)
{
    int tmp = 0;

    //   絶対値をとることで、a, b のいずれか、または
    //   両方が負であっても通用するようになる
    a = abs(a);
    b = abs(b);

    while (b != 0) {
        if (b < a) {
            // swap (abs(b) is always bigger than abs(a)
            tmp = a;
            a = b;
            b = tmp;
        }
        //
        // s/%/-/ は正しいが、b と a の値の差が圧倒的に大きい
        // ときにずっと同じ値 a を引きつづけるため、非常に遅い
        //
        // b の方が大きい限り a を引き続けるということは、いず
        // れは a で割った余りを求めることと同義になる。よって
        // b % a の方が圧倒的に速い
        //
        // ※  % 演算子のオペランドが負であったときの結果は処理系
        //     定義であることに注意。だが、ここでは a, b は常に
        //     正になるように補正しているので無問題
        //
        b = b % a;
        // printf("a:%d b:%d\n", a, b);
    }
    return a;
}

int main(){
    int N;
    scanf("%d", &N);
    int As[112345];
    for(int i=0; i < N; i++){
        scanf("%d", As+i);
    }
    int n = As[0];
    for(int i=1; i < N; i++){
        n = gcd(n, As[i]);
    }
    printf("%d\n", n);
    return 0;
}

Measured memory_bytes: 512
N = int(input())
A = [0] + list(map(int,input().split())) + [0]
B = [0] * (N+1)
total = 0
for i in range(N+1):
    B[i] = A[i+1]-A[i]
    total += abs(B[i])
for i in range(N):
    print(total - (abs(B[i])+abs(B[i+1])) + abs(B[i]+B[i+1]))


Measured memory_bytes: 20560
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


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

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
from math import sqrt

def isPrime(x):
    if x == 2:
        return True

    if x < 2 or x % 2 == 0:
        return False

    i = 3
    while i <= sqrt(x):
        if x % i == 0:
            return False
        i += 2

    return True


row_num = int(input())
count = 0
for row in range(row_num):
    if isPrime(int(input())):
        count += 1

print(count)



Measured memory_bytes: 5676
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
int main()
{
	char a[1010];
	scanf("%s", a);
	int lena = strlen(a);
	if (a[lena - 1] == 's')
	{
		printf("%s", a);
		printf("es");
	}
	else
	{
		printf("%s", a);
		printf("s");
	}
}

Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,L;
    cin>>N>>L;
    int sum=0;
   
    int R=L+N-1;

    int minv;
    if(R<=0)minv=R;
    else if(L>=0)minv=L;
    else minv=0;
    
    int eat=(R+L)*(R-L+1)/2-minv;

    cout<<eat<<endl;
}

Measured memory_bytes: 256
dic = {}
dic['a'] = input()
dic['b'] = input()
dic['c'] = input()
turn = dic['a']
next = 'a'
while dic[next] !='':
    if turn[0] == 'a':
        dic[next] = turn[1:]
        turn = dic['a']
        next = 'a'
    elif turn[0] == 'b':
        dic[next] = turn[1:]
        turn = dic['b']
        next = 'b'
    else:
        dic[next] = turn[1:]
        turn = dic['c']
        next = 'c'
print(next.upper())

Measured memory_bytes: 9156
abc = sorted(list(map(int, input().split())))
cnt = (abc[2] - abc[1]) % 2 + (abc[2] - abc[0]) % 2
if cnt == 0:
    ans = (3 * abc[2] - sum(abc)) // 2
elif cnt == 1:
    ans = (3 * abc[2] - sum(abc) + 1) // 2 + 1
elif cnt == 2:
    ans = (3 * abc[2] - sum(abc) - 2) // 2 + 1
print(ans)


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

int main() {
  int M1,D1,M2,D2;
  cin >> M1 >> D1 >> M2 >> D2;
  if(M1!=M2){
  	cout << 1 << endl; 
  }else{
  	cout << 0 << endl;
  }
  return 0;
}


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

int main() {
    int n; cin >> n;
    cout << n*(n+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int min,max,N;
    cin >>N;
    
    vector<int>vec(N);
    
    for (int i=0;i<N;i++){
        cin >> vec[i];
    }
    
    sort(vec.begin(),vec.end());
    
    min=vec[0];
    reverse(vec.begin(),vec.end());
    max=vec[0];
    
    cout << max-min <<endl;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  
  if(a == 1) a = 14;
  if(b == 1) b = 14;
  
  if(a > b) cout << "Alice" << endl;
  else if(a < b) cout << "Bob" << endl;
  else cout << "Draw" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int n,k,cnt=0;
  string s;
  cin >> n >> k >> s;
  for(int i=0; i<n-1; i++) {
    if(s[i]==s[i+1]) {
      cnt++;
    }
  }
  cout << min(n-1,cnt+2*k) << endl;
}

Measured memory_bytes: 512
def main():
    h, w = map(int, input().split())
    m = []

    for _ in range(h):
        line = input()
        m.append(line)

    if judge_map(m):
        print('Yes')
    else:
        print('No')

def judge_map(m):
    for i in range(len(m)):
        for j in range(len(m[i])):
            if not judge(m, i, j):
                return False
    return True

def judge(m, i, j):
    if m[i][j] == '.':
        return True
    
    if i - 1 >= 0 and m[i - 1][j] == '#':
        return True
    
    if i + 1 < len(m) and m[i + 1][j] == '#':
        return True
    
    if j - 1 >= 0 and m[i][j-1] == '#':
        return True
    
    if j + 1 < len(m[i]) and m[i][j + 1] == '#':
        return True
    
    return False


main()

Measured memory_bytes: 3064
c = []

n = int(input())
c = input()
counterR = 0
counterW = 0
flag = 0

for i in range(n):
    if(c[i] == 'R'):
        counterR += 1 # the number of 'R'

if(counterR == n): # if c[i] are all 'R'
    print('0')
    flag = 1

else:
    for i in range(counterR):
        if(c[i] == 'W'):
            counterW += 1

if(flag == 0):
    print(counterW)


Measured memory_bytes: 9484
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<set>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF 1000000100
#define rep(i,n) for (int i=0;i<n;i++)

int main(){
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i,N) cin >> v[i];
    sort(v.rbegin(), v.rend());
    double a=v.back();
    v.pop_back();
    rep(i,N-1){
        double b=v.back();
        v.pop_back();
        a = (a+b)/2;
    }
    cout << a << endl;
    return 0;
    
    
}


Measured memory_bytes: 3196
A,B,C,K=list(map(int,input().split()))

count=K
point=0

if A>count:
    point+=count
    count=0
else:
    point+=A
    count-=A

if B>count:
    point+=count*0
    count=0
else:
    point+=B*0
    count-=B

if C>count:
    point+=count*(-1)
    count=0
else:
    point+=C*(-1)
    count-=C

print(point)

Measured memory_bytes: 9168
#include <stdio.h>
#include <string>

int main()
{
	char n[3];
	
    // 整数の入力
    scanf("%s", n);
	std::string str = n;

	if(str.length() == 3){
		auto temp = str[2];
		str[2] = str[0];
		str[0] = temp;
	}

    // 出力
    printf("%s\n", str.c_str());
    return 0;
}

Measured memory_bytes: 888