akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

struct UnionFind{
    vector<int> d;

    /* 初期化 */
    UnionFind(int n = 0) : d(n , -1) {}

    /* 検索 */
    int find(int x){
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    /* 結合 */
    bool unite(int x, int y){
        x = find(x); y = find(y);
        if (x == y) return false;
        if (x > y) swap(x ,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    /* 結合リスト内か */
    bool same(int x, int y) { return find(x) == find(y); }

    /* サイズ */
    int size(int x) { return -d[find(x)]; }
};

int deg[100005];

int main()
{
    int n, m;
    cin >> n >> m;
    UnionFind tree(n);
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        deg[p[i]] = i;
    }
    for (int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        --x; --y;
        tree.unite(x, y);
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        if (p[i] == i + 1) ans++;
        else{
            int pos = deg[i + 1];
            if(tree.same(i, pos)) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
import scala.io.StdIn._
import scala.math._

object Main extends App with StdInHelper {
  val Array(n, k) = readInts

  var sunuke = (1 to n).toIndexedSeq

  for (_ <- 1 to k) {
    val d = readInt
    val as = readInts
    as.foreach { a => sunuke = sunuke.filterNot(_ == a) }
  }

  println(sunuke.length)
}

trait StdInHelper {
  def readInts = readLine.split(" ").map(_.toInt)
  def readLongs = readLine.split(" ").map(_.toLong)
}


Measured memory_bytes: 56352
#include<stdio.h>
#include<string.h>
int main(void)
  {
    int n,i,d,scoret=0,scoreh=0;
    char cardt[101],cardh[101];
    scanf("%d",&n);
    for(i=0;i<n;i++)
  {
    scanf("%s %s",cardt,cardh);
    d=strcmp(cardt,cardh);
    if(d==0){scoret++;scoreh++;}
    else if(d>0){scoret+=3;}
    else{scoreh+=3;}
  }
    printf("%d %d\n",scoret,scoreh);
 
    return 0;
  }


Measured memory_bytes: 2088
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>

#define S true
#define W false
#define undefined -1

#define O 'o'
#define X 'x'

#define before(i) (i == 0) ? N - 1 : i - 1
#define next(i) (i == N - 1) ? 0 : i + 1

bool checkValid(char *animals, char *comments, int N, int index) {
	return (comments[index] == O && (animals[next(index)] == animals[before(index)]) == animals[index])
	       || (comments[index] == X && (animals[next(index)] != animals[before(index)]) == animals[index]);
}
int main(void) {
	int N, i, j, nextJ;
	char *animals, *comments;
	char initial0[4] = {S, S, W, W}, initial1[4] = {S, W, S, W};
	scanf("%d", &N);
	animals = malloc(N * sizeof(char));
	comments = malloc(N * sizeof(char));
	scanf("%s", comments);
	for (i = 0; i < 4; i++) {
		for (j = 0; j < N; j++) {
			animals[j] = undefined;
		}
		animals[0] = initial0[i];
		animals[1] = initial1[i];
		for (j = 1; j < N - 1; j = nextJ) {
			nextJ = next(j);
			if (animals[j] == S) {
				if (comments[j] == O) {
					animals[nextJ] = animals[j - 1];
				}
				else {
					animals[nextJ] = !animals[j - 1];
				}
			}
			else {
				if (comments[j] == O) {
					animals[nextJ] = !animals[j - 1];
				}
				else {
					animals[nextJ] = animals[j - 1];
				}
			}
		}
		if (checkValid(animals, comments, N, 0) && checkValid(animals, comments, N, N - 1)) {
			for (j = 0; j < N; j++) {
				printf("%c", animals[j] == S ? 'S' : 'W');
			}
			printf("\n");
			return 0;
		}
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template<class T> bool chmax(T& a,T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a,T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	int n;
	long long k;
	cin >> n >> k;
	vector<int> a(n);
	for (int &e : a) {
		cin >> e;
		e--;
	}
	
	vector<vector<int>> dat(63, vector<int>(n));
	for (int i = 0; i < n; i++) dat[0][i] = a[i];
	for (int i = 1; i < 63; i++) {
		for (int j = 0; j < n; j++) {
			dat[i][j] = dat[i - 1][dat[i - 1][j]];
		}
	}
	
	int ans = 0;
	for (int i = 0; i < 63; i++) {
		if (k & (1LL << i)) ans = dat[i][ans];
	}
	
	cout << ans + 1 << '\n';
	return 0;
}

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

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  vector<ll> A(N + 1, 0);
  vector<ll> B(M + 1, 0);
  for (int i = 1; i <= N; i++) {
    cin >> A.at(i);
    A.at(i) += A.at(i - 1);
  }
  for (int i = 1; i <= M; i++) {
    cin >> B.at(i);
    B.at(i) += B.at(i - 1);
  }

  int j = M;
  int ans = 0;
  rep(i, N + 1) {
    if (A.at(i) > K) break;
    while (A.at(i) + B.at(j) > K && j > 0) j--;
    ans = max(ans, i + j);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6440
s = [input() for i in range(2)] 
li = list(map(int, s[1].split()))
s0 = int(s[0])
f1 = 1
if 0 in li:
    print(0)
if 0 not in li:
    for i in range(s0):
        f1 = f1 * li[i]
        if f1 > 1000000000000000000:
            print(-1)
            break
    if f1 <= 1000000000000000000:
        print(f1)



Measured memory_bytes: 23748
#include<stdio.h>
#define N 100
#define MAX 2000
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2


int A[N][N], n;

int prim(){
  int i, u, v, minv, sum = 0;
  int d[N], p[N], color[N];

  for( i = 0 ; i < n ; i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }
  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for( i = 0; i < n ; i++){
      if(minv > d[i] && color[i] != BLACK){
        u = i;
        minv = d[i];
      }
    }
    if( u == -1 ) break;
    color[u] = BLACK;
    for( v = 0 ; v < n ; v++){
      if( color[v] != BLACK && A[u][v] != INFTY ){
        if( d[v] > A[u][v] ){
          d[v] = A[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
  for( i = 0 ; i < n ; i++ ){
    if( p[i] != -1 ) sum += A[i][p[i]];
  }

  return sum;
}

int main(){
  int i, j, s;
  scanf("%d", &n);
  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j ++){
      scanf("%d", &s);
      A[i][j] = (s == -1) ? INFTY : s;
    }
  }

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

  return 0;
}



Measured memory_bytes: 2052
S = input()[::-1]

sum_of_digits = 0

cnts = [0] * 2019
cnts[0] = 1
d = 1

for c in S:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
    d %= 2019
    cnts[sum_of_digits] += 1

ans = 0

for cnt in cnts:
    ans += cnt * (cnt - 1) // 2

print(ans)


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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


int main(void){

	string S; cin >> S;
	
	if(S == "SUN") cout << 7 << endl;
	if(S == "MON") cout << 6 << endl;
	if(S == "TUE") cout << 5 << endl;
	if(S == "WED") cout << 4 << endl;
	if(S == "THU") cout << 3 << endl;
	if(S == "FRI") cout << 2 << endl;
	if(S == "SAT") cout << 1 << endl;


	return 0;

}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

typedef tuple<ll,ll,ll> P;

#define MT make_tuple


int main(){
    ll a,b,c,n;
    cin>>a>>b>>c>>n;
    map<P,ll> cnt;
    ll ans=(a*b+b*c+c*a)*2;
    set<P> rem;
    for(int i=0;i<n;i++){
        P W;
        ll x,y,z;
        cin>>get<0>(W)>>get<1>(W)>>get<2>(W);
        x=get<0>(W);
        y=get<1>(W);
        z=get<2>(W);
        ll ct=0;
        if(x==0){ct++;}
        if(x==a-1){ct++;}
        if(y==0){ct++;}
        if(y==b-1){ct++;}
        if(z==0){ct++;}
        if(z==c-1){ct++;}
        if(cnt.count(W)){
            ct+=cnt[W];
            cnt.erase(W);
        }
        ans-=ct;
        if(x!=0 && !rem.count(MT(x-1,y,z))){cnt[MT(x-1,y,z)]++; ans++;}
        if(x!=a-1 && !rem.count(MT(x+1,y,z))){cnt[MT(x+1,y,z)]++; ans++;}
        if(y!=0 && !rem.count(MT(x,y-1,z))){cnt[MT(x,y-1,z)]++; ans++;}
        if(y!=b-1 && !rem.count(MT(x,y+1,z))){cnt[MT(x,y+1,z)]++; ans++;}
        if(z!=0 && !rem.count(MT(x,y,z-1))){cnt[MT(x,y,z-1)]++; ans++;}
        if(z!=c-1 && !rem.count(MT(x,y,z+1))){cnt[MT(x,y,z+1)]++; ans++;}
        rem.insert(W);
    }
    cout<<ans<<endl;
    
    
    return 0;
}



Measured memory_bytes: 3656
#include<stdio.h>
int main(){
  int a,b,d,r;
  double f;
  scanf("%d %d",&a,&b);
  d=a/b;
  r=a%b;
  f=(double)a/(double)b;
  printf("%d %d %f\n",d,r,f);
  return 0;
}

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

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

    bool ans = false;
    for (int i = 1; i <= 9; i++){
        for (int j = 1; j <= 9; j++){
            if (i * j == N){
                ans = true;
                break;
            }
        }
        if (ans){
            break;
        }
    }
    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define mod 1000000007
#define INF 2147483647
#define fi first
#define se second
int abs(int a,int b){
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<pair<int,int> >a;
  int b,c,d;
  cin>>b;
  for(int i=0;i<b;i++){
    cin>>c;
    a.push_back(make_pair(c,i));
  }
  sort(a.begin(),a.end());
  for(int i=0;i<b;i++){
    cout<<a[i].se+1<<"\n";
  }
}


Measured memory_bytes: 1780
import java.util.*;
public class Main
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt(); long constant = 0;
        TreeMap<Integer, Integer> map = new TreeMap<>(); int ptr = -1; int idx = -1; int total = 0;
        long val = 0;
        for (int i = 0; i < q; i++) {
            if (sc.nextInt() == 1) {
                int a = sc.nextInt(); int b = sc.nextInt();
                constant += b;
                map.put(a, map.getOrDefault(a, 0) + 1);
                if (ptr == -1) {
                    ptr = a; idx = 1;
                } else if (a < ptr) {
                    val += Math.abs(a - ptr);
                    if (total % 2 == 1) {
                        idx--;
                        if (idx == 0) {
                            ptr = map.lowerKey(ptr);
                            idx = map.get(ptr);
                        }
                    }
                } else if (a > ptr) {
                    val += Math.abs(a - ptr);
                    if (total % 2 == 0) {
                        idx++;
                        if (idx > map.get(ptr)) {
                            int newPtr = map.higherKey(ptr);
                            val -= (newPtr - ptr);
                            ptr = newPtr;
                            idx = 1;
                        }
                    }
                } else {
                    if (total % 2 == 0) {
                        idx++;
                    }
                    val += Math.abs(ptr - a);
                }
                total++;
            } else {
                System.out.println(ptr + " " + (val + constant));
            }
        }
    }


}

Measured memory_bytes: 70672
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    range(i, 1, 10) {
        if (N % i == 0 and N / i <= 9) {
            cout << "Yes" << "\n";
            return 0;
        }
    }
    cout << "No" << "\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;

vector<int> G[100010];
int n;

int color[100010];
map<P,int> ma;

bool visit[100010];
void dfs(int v,int cl)
{
	visit[v]=true;
	int imacl=0;
	for(int i=0;i<G[v].size();i++)
	{
		int w=G[v][i];
		if(visit[w])continue;
		if(imacl==cl)imacl++;
		color[ma[P(v,w)]]=imacl;
		dfs(w,imacl); 
		imacl++;
	}
}
int main(){
	cin>>n;
	fill(visit,visit+n,false);
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;a--;b--;
		ma[P(a,b)]=i;
		ma[P(b,a)]=i;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(0,100100100);
	int MAX=0;
	for(int i=0;i<n-1;i++)MAX=max(MAX,color[i]);
	
	cout<<MAX+1<<"\n";
	for(int i=0;i<n-1;i++)cout<<color[i]+1<<"\n";
	return 0;
}

Measured memory_bytes: 19328
while True:
    H, W = list(map(int, input().split()))
    if H == 0 and W == 0:
        break

    for i in range(H):
        for j in range(W):
            if i == 0 or i == H - 1 or j == 0 or j == W - 1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()



Measured memory_bytes: 7004
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = ((int)(n) - 1); i >= 0; i--)
#define repn(i, n) for(int i = 1; i <= (int)(n); i++)
#define reprn(i, n) for(int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define LARGE_PRIME_NUM 1000000007
typedef long long ll;

#include <iostream>
#include <array>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <numeric>
#include <cmath>

using namespace std;

bool compare(pair<pair<string, int>, int> a, pair<pair<string, int>, int> b) {
	if (a.first.first != b.first.first) {
		return a.first.first < b.first.first;
	} else {
		return a.first.second > b.first.second;
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> k;
	vector<vector<int>> s;
	rep(i, m) {
		int ki;
		cin >> ki;
		k.push_back(ki);
		vector<int> sk;
		rep(j, ki) {
			int skj;
			cin >> skj;
			sk.push_back(skj);
		}
		s.push_back(sk);
	}
	vector<int> p;
	rep(i, m) {
		int pi;
		cin >> pi;
		p.push_back(pi);
	}
	int ans = 0;
	rep(i, pow(2, n)) {
		bool flag = true;
		rep(j, m) {
			int sum = 0;
			rep(ii, k[j]) {
				if (((i >> (s[j][ii] - 1)) & 1) == 1) {
					sum++;
				}
			}
			if (sum % 2 != p[j]) {
				flag = false;
			}
		}
		if (flag) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	int n;
	cin>>n;
	int *A=new int[n];
	for(int i=0;i<n;++i)cin>>A[i];
	int q,k,sum=0;
    cin>>q;
    for(int i=0;i<q;++i){
    	cin>>k;
    	if(binary_search(A,A+n,k))sum++;
    }
    cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3476
x1, y1, x2, y2 = map(int, input().split())
x4 = x1 - y2 + y1
x3 = x4 + x2 - x1
y4 = y1 + x2 - x1
y3 = y4 + y2 - y1
print(x3, y3, x4, y4)

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

void solve() {
	int a, b;
	vector<pair<int, int> > edges;
	int maxNode = 0;
	while (cin >> a >> b, a || b) {
		maxNode = max(a, max(b, maxNode));
		edges.push_back(make_pair(a, b));
	}
	if (!cin.good()) return;
	int nodes[maxNode];
	memset(nodes, 0, sizeof(nodes));
	for (unsigned i = 0; i < edges.size(); i++) {
		nodes[edges[i].first - 1]++;
		nodes[edges[i].second - 1]++;
	}
	if (!(nodes[0] & 1u) || !(nodes[1] & 1u)) {
		cout << "NG" << endl;
		return;
	}
	for (int i = 2; i < maxNode; i++) {
		if (nodes[i] & 1u) {
			cout << "NG" << endl;
			return;
		}
	}
	cout << "OK" << endl;
}

int main () {
	while (cin.good()) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 1204
#include<stdio.h>
int main(){
  int n,i,d[100010],l,max=0,mi=1;
  scanf("%d",&n);
  for(i=1;i<n;i++){
    printf("? 1 %d\n",i+1);
    fflush(stdout);
    scanf("%d",&l);
    if(max<l){
      max=l;
      mi=i+1;
    }
  }
  for(i=0;i<n;i++){
    printf("? %d %d\n",mi,i+1);
    fflush(stdout);
    scanf("%d",&l);
    d[l]=i+1;
  }
  printf("!");
  for(i=0;i<n;i++)printf(" %d",d[i]);
  printf("\n");
  fflush(stdout);
  return 0;
}
  

Measured memory_bytes: 1600
#include<iostream>
using namespace std;
int main(){
  char b;
  cin >> b;
  char ans;
  switch(b){
    case 'A': ans = 'T'; break;
    case 'C': ans = 'G'; break;
    case 'G': ans = 'C'; break;
    case 'T': ans = 'A'; break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// Square Route
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int N = sc.nextInt();
			int M = sc.nextInt();
			if ((N | M) == 0)
				break;
			int[] h = new int[N];
			int[] w = new int[M];
			List<Integer> list = new ArrayList<Integer>();
			int max = 0;
			for (int i = 0; i < N; i++) {
				h[i] = sc.nextInt();
				int t = 0;
				for (int j = i; j >= 0; j--) {
					t += h[j];
					list.add(t);
					max = Math.max(t, max);
				}
			}
			int[] results = new int[max + 1];
			int result = 0;
			for (int i = 0; i < list.size(); i++)
				results[list.get(i)]++;
			for (int i = 0; i < M; i++) {
				w[i] = sc.nextInt();
				int t = 0;
				for (int j = i; j >= 0; j--) {
					t += w[j];
					if (t <= max)
						result += results[t];
				}
			}
			System.out.println(result);
		}
		sc.close();
	}
}

Measured memory_bytes: 175092
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  long long v_t = 0;
  long long v_a = 0;
  
  vector<int> t(N);
  vector<int> a(N);
  rep(i, N) {
    cin >> t[i];
    cin >> a[i];
  }

  rep(i, N) {
    if (v_t <= t[i] && v_a <= a[i]) {
      v_t = t[i];
      v_a = a[i];
    } else {
      long long m = std::max(v_t / t[i], v_a / a[i]);
      while (true) {
        if (v_t <= m * t[i] && v_a <= m * a[i]) {
          v_t = m * t[i];
          v_a = m * a[i];
          break;
        }

        m++;
      }
    }
  }

  cout << v_t + v_a << endl;

  return 0;
}


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

int main() {
  //input
  int64_t N;
  cin >> N;
  vector<int64_t> A(N);
  rep(i,N) {
    cin >> A.at(i);
  }
  //calc
  int64_t ans = 0;
  int64_t S = 0;
  for(int i = N-2; i >= 0; i--) {
    S += A.at(i+1);
    S %= P;
    ans += A.at(i) * S;
    ans %= P;
  }
  //output
  cout << ans << endl;
}

Measured memory_bytes: 4812
#include<stdio.h>

int main(void)
{
    int A,B;
    scanf("%d%d",&A,&B);

    if(A>=13){
        printf("%d",B);
    }
    else if(A<=12 && A>=6){
        printf("%d",B/2);
    }
    else{
        printf("%d",0);
    }
    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int a, b; cin >> a >> b;
    int cnt = 0;
    rept(i, a, b+1){
        string s = to_string(i);
        string t = s; reverse(all(t));
        if(s==t)cnt++;
    }
    cout << cnt << ln;
}


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

#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()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


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

  cout << (n<1000 ? "ABC" : "ABD") << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	//cout << fixed << setprecision(10);
	int n; cin>>n;
	vvi vec(4,vi(13));
	rep(i,0,n){
		char c; int a; 
		cin >> c >> a;
		--a;
		if(c=='S')vec[0][a]=1;
		else if(c=='H')vec[1][a]=1;
		else if(c=='C')vec[2][a]=1;
		else vec[3][a]=1;
	}
	rep(i,0,4){
		char c;
		if(i==0)c='S';
		else if(i==1)c='H';
		else if(i==2)c='C';
		else c='D';
		rep(j,0,13){
			if(!vec[i][j])cout<<c<<" "<<j+1<<endl;
		}
	}


	return 0;
}


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

template<class T, class Func = function<T(T, T)>>
class segtree {
    vector<T> obj;
    int offset;
    Func updater;
    T e;
    int bufsize(int num) {
        int i = 1;
        for (; num + 1 >i; i <<= 1);
        offset = i - 1;
        return (i << 1) - 1;
    }
    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l)return e;
        if (a <= l && r <= b)return obj[k];
        else return updater(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
    }
public:
    T query(int a, int b) {//[a,b)
        return query(a, b, 0, 0, offset + 1);
    }
    void updateall(int l = 0, int r = -1) {
        if (r < 0)r = offset + 1;
        l += offset, r += offset;
        do {
            l = (l - 1) >> 1, r = (r - 1) >> 1;
            for (int i = l; i > r; i++)obj[i] = updater(obj[i * 2 + 1], obj[i * 2 + 2]);
        } while (l);
    }
    void update(int k, T &a) {
        k += offset;
        obj[k] = a;
        while (k) {
            k = (k - 1) >> 1;
            obj[k] = updater(obj[k * 2 + 1], obj[k * 2 + 2]);
        }
    }
    segtree(int n, T e, const Func &updater = Func()) :obj(bufsize(n), e), e(e), updater(updater) {}
    segtree(vector<T> &vec, T e, const Func &updater = Func()) :obj(bufsize(vec.size()), e), e(e), updater(updater) {
        copy(vec.begin(), vec.end(), obj.begin() + offset);
        updateall();
    }
    typename vector<T>::reference operator[](int n) {
        return obj[n + offset];
    }
};

using namespace std;
int main(){
  int N; cin >> N;
  int Q; cin >> Q;
  using Int = long long;
  vector<Int>v(N,0LL);
  Int e = 0LL;
    auto sgt = segtree<Int>(v,e,[](Int a,Int b){return a + b;});
  for(int _ = 0; _ < Q; ++_){
    int com; cin >> com;
    if(com == 0){
      Int x,y; cin >> x >> y;
      --x;
      auto cp = sgt[x] + y;
      sgt.update(x,cp);
    } else {
      Int x,y; cin >> x >> y;
      --x;
      cout << sgt.query(x,y) << endl;
    }
  }
}



Measured memory_bytes: 5772
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            //string s = Console.ReadLine();

            // 整数の入力
            long K = long.Parse(Console.ReadLine());

            // 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var A = inputLongArray[0];
            var B = inputLongArray[1];
            long j;
            string result = "NG";

            for (j = A;j<= B; j++)
            {
                if (j % K == 0)
                {
                    result = "OK";
                    
                }
                        
            }


            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28196
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    int A,B; cin >> A >> B;
    if(A==1) A+=13; 
    if(B==1) B+=13;
    
    if(A > B){
        pr("Alice");
    }else if(A < B){
        pr("Bob");
    }else{
        pr("Draw");
    }
    
}


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

using namespace std;

int main(int argc, char *argv[]) {
    string S;
    cin >> S;
    if (S == "AAA" || S == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int isprime(int x){
	int i;
	if(x == 2){
 		return 1;
	}
  	if(x<2||x%2==0){
		return 0;
	}
	i = 3;
	while( i <= sqrt(x) ){
		if(x%i==0){
			return 0;
		}
		i = i + 2;
	}
	return 1;
}
int main()
{
	int n,c=0,l[10001]={0},j=0;
	for(int i=0;i<=104730;i++){
		if(isprime(i)){
			c+=i;
			l[j]=c;
			j++;
		}
	}
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		printf("%d\n",l[n-1]);
	}
	return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
double distance(int a, int b, int c, int d) { return sqrt((a - c) * (a - c) + (b - d) * (b - d)); }
int main() {
    int N;
    cin >> N;
    vector<int> list(N);
    rep(i, N) { cin >> list[i]; }
    sort(all(list), greater<int>());
    int ans = 0;
    rep(i, N){
      if (i % 2 == 0) {
        ans += list[i];
      } else {
        ans -= list[i];
      }
    }
  cout << ans;
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の string型配列と同じような感じ）
map<int, string> mp;
for (auto itr =mp.begin(); itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[3000000],arr1[3000000],cum[3000000],cum1[3000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long n,m,k,i,j,x,y,z,a,b,z1,c,cc;
    cin>>n>>m>>k;
    a=0;
    for (i=1;i<=n;i++)
    {
    	cin>>arr[i];
    	cum[i]=cum[i-1]+arr[i];
	}
	for (i=1;i<=m;i++)
	{
		cin>>arr1[i];
		cum1[i]=cum1[i-1]+arr1[i];
	}
	z=0;
	for (i=0;i<=n;i++)
	{
		if (cum[i]>k)
		{
			break;
		}
	}	
	z=i-1;
	x=z;
	y=0;
//	for (i=1;i<=m;i++)
//	{
//		if (b<cum1[i])
//		{
//			break;
//		}
//	}
//	//cout<<z<<endl;
//	y=i-1;
//	z+=y;
	//cout<<y<<endl;
	b=0;
	while (1)
	{
		if (y==m && x==0)
		{
			break;
		}
		y++;
		if (y>m)
		{
			y=m;
		}
		c=cum1[y]+cum[x];
		if (c<=k)
		{
			cc=x+y;
			z=max(z,cc);
			if (y==m)
			{
				break;
			}
		}
		else
		{
			x--;
			if (x<0)
			
			{
				x=0;
			}
		}

	}

	cout<<z<<endl;	
}

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

using namespace std;

using ll = long long;
ll epow(ll a, ll b) {
    ll ret = 1;
    while (b) {
        if (b & 1) 
            ret *= a;
        a *= a;
        b >>= 1;
    }
    return ret;
}

int main(void) {
    ll x;
    pair<ll, ll> ans = {-1, -1};
    scanf("%lld", &x);
    for (ll i = -200; i <= 200; i++) {
        for (ll j = -200; j <= 200; j++) {
            ll a = epow(i, 5);          
            ll b = epow(j, 5);
            if (a - b == x) {
                ans = {i, j};
                break;
            }
        }
        if (ans.first != -1 && ans.second != -1)
            break;
    }
    printf("%lld %lld\n", ans.first, ans.second);
    return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long

void solve(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++) cin >> a[i];
	ll sum = 0;
	map<int, int> mp;
	for(int i=0; i<n; i++) {
		sum += a[i];
		mp[a[i]]++;
	}
	// cout << sum << endl;
	int q;
	cin >> q;
	while(q--){
		int x, y; 
		cin >> x >> y;
		sum += (mp[x] * (y-x));
		cout << sum << '\n';
		if(x != y) mp[y] += mp[x];
		mp[x] = 0;
	}
}

int main(){
	IOS;
	int t = 1; 
	// cin >> t;
	while(t--) solve();
	return 0;
}

Measured memory_bytes: 8064
#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()
#define let auto const

int main() {
  i64 n;
  cin >> n;
  rep(q,0,n) {
    i64 y, m, d;
    cin >> y >> m >> d;
    i64 dd = d;
    i64 mm;
    if(y % 3 == 0) mm = 20 * (m - 1);
    else mm = 20 * (m - 1) - (m - 1) / 2;
    i64 yy = (195 + 195 + 200) * ((y - 1) / 3);
    yy += 195 * ((y - 1) % 3);
    cout << 196471 - dd - mm - yy << endl;
  }
}



Measured memory_bytes: 3092
#include <stdio.h>
int main(void){
	char s1, s2, s3, s4;
	scanf("%c%c%c%c", &s1, &s2, &s3, &s4);
	if (s1 == s2 || s2 == s3 || s3 == s4) printf("Bad");
	else printf("Good");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int a[3];
	for (auto& x : a) {
		cin >> x;
	}
	sort(rbegin(a), rend(a));
	int ans = 10 * a[0] + a[1] + a[2];
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(it,beg,end) for(__typeof(beg) X=beg,Y=end,it=(X>Y?X-1:X);it!=(X>Y?Y-1:Y);it+=(X>Y?-1:1))
using namespace std;
#define ll long long
#define pb emplace_back
#define mp make_pair
inline void read1(ll &n) {
	char c;n=0;ll x=1;
	while (!isdigit(c=fgetc(stdin))&&c!='-');
	if (c=='-') x=-1, c=fgetc(stdin);
	while (isdigit(c)) n=n*10+c-'0',c=fgetc(stdin);
	n*=x;
}
inline void read1(int &n) {ll x;read1(x);n=x;}
#define read2(a,b) {read1(a);read1(b);}
#define read3(a,b,c) {read1(a);read1(b);read1(c);}
#define read4(a,b,c,d) {read1(a);read1(b);read1(c);read1(d);}
// -------------------- Standard Template --------------------
int N;
int main() {
	read1(N);
	double x=4.0/N;
	rep(h,1,3501) rep(n,1,3501) {
		int w=1.0/(4.0/N-1.0/h-1.0/n);
		if (w>0&&1.0/h+1.0/n+1.0/w==x) {
			printf("%d %d %d\n",h,n,w);return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        String str = sc.next();
        int n = str.length();

        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++) {
            sb.append("x");
        }
        System.out.print(sb.toString());
    }
}


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

using namespace std;

const int N = 101000;

int v[N];

int main() {
	int n, c, k;
	scanf("%d%d%d", &n, &c, &k);

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

	for (int i = 0; i < n; ++i) {
		int s = i;
		while(s < n && v[s] <= v[i] + k && s-i < c) {
			s++;
		}
		val++;
		i = s-1;
	}
	printf("%d\n", val);
}

Measured memory_bytes: 640
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;
import std.numeric;
import std.bigint;
import core.checkedint;

void main()
{
	for (;;) {
		int n = readln.chomp.to!int;
		if (n == 0) {
			break;
		}
		char[char] dic;
		foreach (i; 0..n) {
			auto raw = readln.chomp;
			dic[raw[0]] = raw[2];
		}
		int m = readln.chomp.to!int;
		foreach (i; 0..m) {
			auto c = readln[0];
			if (c in dic) {
				dic[c].write;
			} else {
				c.write;
			}
		}
		writeln;
	}
}

void tie(R, Args...)(R arr, ref Args args)
		if (isRandomAccessRange!R || isArray!R)
in
{
	assert (arr.length == args.length);
}
body
{
	foreach (i, ref v; args) {
		alias T = typeof(v);
		v = arr[i].to!T;
	}
}

void verbose(Args...)(in Args args)
{
	stderr.write("[");
	foreach (i, ref v; args) {
		if (i) stderr.write(", ");
		stderr.write(v);
	}
	stderr.writeln("]");
}



Measured memory_bytes: 3148
import itertools
N, M = map(int,input().split())
s = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
ans = 0
   
for i in itertools.product([0,1], repeat=N):
    dame = 0
    for j in range(M):
        temp = p[j]
        for k in s[j][1::]:
            temp += i[k-1]
        if temp%2:
            dame = 1
    if not dame:
        ans += 1
print(ans)
    

Measured memory_bytes: 9100
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,e=0,d=0;
    scanf("%d%d%d",&a,&b,&c);
    if(a==5)
        d++;
    else if(a==7)
        e++;
    if(b==5)
        d++;
    else if(b==7)
        e++;
    if(c==5)
        d++;
    else if(c==7)
        e++;
   if(d==2&&e==1)
    printf("YES\n");
   else printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
  char s[1201];
  scanf("%[^\n]",s);

  for(int i = 0;s[i]!='\0';i++) {
    if(isupper(s[i])) {
      s[i] = tolower(s[i]);
    } else if(islower(s[i])) {
      s[i] = toupper(s[i]);
    }
    printf("%c", s[i]);
  }
  printf("\n");

  
  return 0;
}



Measured memory_bytes: 3160
package main

import "fmt"

func main() {
	var w, h, x, y float64
	fmt.Scan(&w, &h, &x, &y)

	fmt.Printf("%f ", w*h/2.0)
	if x+x == w && y+y == h {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}


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

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int nn = scan.nextInt();

		int[] aiai;
		aiai = new int[nn];

		long total = 0;
		for (int i = 0; i < nn; i++) {
			aiai[i] = scan.nextInt();
			total = total + aiai[i];
		}

		Arrays.sort(aiai);
		System.out.println(aiai[0] + " " + aiai[nn - 1] + " " + total);

	}

}

Measured memory_bytes: 42160
function Main(input) {
	var data = input.split("\n");
	var n = data[0];
	var masu =  data[1].split(" ").map((n) => parseInt(n, 10));
	var max = 0;
	var t = 0;
	for(var i = (n - 1); i>=0; i--){
		if(masu[i] <= masu[i-1]){
			t++;
			if(t>max) max = t;
		}else if(masu[i] > masu[i-1]){
			t = 0;
		}
	}
	console.log(max)
}
 
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21828
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define vl          vector<ll>
#define ld          long double
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pi          3.14159265358979323


void solve()
{
       ll n; cin>>n;
       ll ans=3*n*n;
       cout<<ans<<endl;
}

int main(){
	int T = 1;
       //pre();
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


Measured memory_bytes: 256
N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))

S = sum(A)
for i in range(N-1,-1,-1):
  if B[i] > 0:
    if A[i+1] < B[i]:
      B[i] = B[i] - A[i+1]
      A[i+1] = 0
    else:
      A[i+1] = A[i+1] - B[i]
      B[i] = 0
  if B[i] > 0:
    if A[i] < B[i]:
      B[i] = B[i] - A[i]
      A[i] = 0
    else:
      A[i] = A[i] - B[i]
      B[i] = 0

print (S - sum(A))

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

int main() {
  int n;
  long k;
  cin >> n >> k;

  vector<int> p(n);
  vector<long> c(n);

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

  long long ans = -10000000000;
  for(int i=0;i<n;i++){
    int now = p[i] -1;
    long long l_s = 0;
    long long tmp = 0;
    vector<int> t;
    t.push_back(c[now]);
    l_s += c[now];
    while(now !=i){
      // cout << l_s << " ";
      now = p[now]-1;
      t.push_back(c[now]);
      l_s += c[now];
    }

    // cout << l_s << endl;

    for (int j=0;j<t.size();j++){
      tmp += t[j];
      if(j+1>k) break;
      long long hoge = tmp;
      if(l_s > 0){
	long long e = (k-(j+1))/t.size();
	hoge += l_s * e;
      }
      ans = max(ans,hoge);
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3728
#include <iostream>

using namespace std;

typedef long long ll;

int t[100001];

int main() {

  int n, q;
  ll a, b, c, res = 0;

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

  cin >> q;
  for(int i=0; i<q; ++i) {
    cin >> b >> c;

    if(t[b]!=0) {
      res += (c-b)*t[b];
      t[c] += t[b];
      t[b] = 0;
    }

    cout << res << endl;
  }

  return 0;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
// #include "bits:stdc++.h"
using namespace std;
#define LLINF 1234567890987654321
#define ph push
#define ins insert
#define db 0
#define f first
#define s second
typedef long long ll;
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
map <ll, ll> mp;
ll n, m, ans, A[100001], sum[100001];
void make_sum(ll i)
{
	if(i==0)sum[i] = A[i];
	else sum[i] = sum[i-1] + A[i];
}
ll get_sum(ll x, ll y)
{
	if(x == 0)return sum[y];
	else return sum[y] - sum[x-1];
}
int main()
{
	cin >> n >> m;
	for(ll i = 0; i < n; i++)cin >> A[i];
	for(ll i = 0; i < n; i++)make_sum(i);
	mp[0] = 1;
  ll lol=0;
	for(ll i = 0; i < n; i++)
	{
		lol+=A[i];
      	ll sum=lol;
		ans += mp[sum%m];
		mp[sum%m]++;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define range(c) c.begin() , c.end()
#define forn(i,n) for(ll i=0; i<n; ++i)
#define endl '\n'
#define MOD 1000000007
#define test ll t;cin >> (t);while(t--)
using namespace std;
//////////////////////////////////////////////////////////////
 ll n;ll W;
// map<pair<ll,ll>,ll> mp;
//  ll a[102][2];
// ll func( ll i, ll w)
// {
//     ll val=a[i][1];
//     ll wt=a[i][0];
//     //cout<<wt<<"\n";
//     if(i>=n)
//         return 0;
//     if(w<0)
//     {
//     // if(mp[make_pair(i,w)] !=0)
//     //     return mp[make_pair(i,w)];
//     // else
//     //     return mp[make_pair(i,w)]=func(i+1,w);
//     return -100000000000000ll;
//     }
//     if(w == 0)
//         return 0;
//     if(mp[make_pair(i,w)]!=0)
//         return mp[make_pair(i,w)];
//     else
//     return mp[make_pair(i,w)]=(max( func( i+1, w), (val + func( i+1, w-wt))));
    
//}
const ll INF=1e18L+5;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    cin >> n >> W;ll val=0;
    ll a[n][2];
    forn(i,n)
    {
        cin >> a[i][0] >> a[i][1];
        val+=a[i][1];
    }
    vector<ll> dp(val+1,INF);
    
   
    dp[0]=0;
    for(ll i=0;i<n;i++)
    {
        for(ll j=val-a[i][1];j>=0;j--)
        {
            dp[j+a[i][1]]=min(dp[j+a[i][1]], dp[j] + a[i][0]);
        }
    }
    // forn(i,val)
    // {
    //     cout << dp[i] << endl;
    // }
    ll ans=0;
    for(ll i=0;i<=val;i++)
    {
        if(dp[i] <= W)
        {
            ans=max(ans,i);
        }
    }
    
    cout << ans << endl;
}
     
    

Measured memory_bytes: 1024
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	ll N, D, X; cin >> N >> D >> X;
	vector<int> A(N); rep(i, N)cin >> A[i];

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j * A[i] + 1 <= D; j++) {
			ans++;
		}
	}

	cout << ans + X << endl;
}

Measured memory_bytes: 256
def fact(n):
    mod = int(1e9)+7
    res = 1
    for i in range(1,n+1):
        res = (res*i)%mod
    return res

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

if abs(N-M) >= 2:
    print(0)
    exit()

mod = int(1e9)+7

if N == M:
    print(2*fact(N)*fact(M)%mod)
else:
    print(fact(N)*fact(M)%mod)


Measured memory_bytes: 3060
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
ll pw(ll a, ll b)
{
    ll r = 1;
    while (b)
    {
        if (b % 2)
            r *= a, r %= M;
        a *= a;
        a %= M;
        b /= 2;
    }
    return r;
}
ll f[N], p[N];
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, k, s = 0;
    cin >> n >> k;
    for (ll i = 1; i <= k; i++)
        p[i] = pw(i, n);
    for (ll i = k; i; i--)
    {
        f[i] = p[k / i];
        for (ll j = i * 2; j <= k; j += i)
            f[i] = (f[i] - f[j] + M) % M;
        s = (s + i * f[i]) % M;
    }
    cout << s;
}

Measured memory_bytes: 5172
while True:
    h, w = input().split()
    h = int(h)
    w = int(w)
    if (h != 0) or (w != 0):
        print("#" * w)
        for i in range(h-2):
            print("#" + "." * (w-2) + "#")
        print("#" * w)
        print() 
    else:
        break


Measured memory_bytes: 5612