akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)

int n,x[101],y[101];
const double PI=acos(-1);
double k[101];

int main(){
	scanf("%d",&n);
	if(n==2){puts("0.5\n0.5");return 0;}
	F(i,1,n) scanf("%d%d",x+i,y+i);
	F(i,1,n){
		int cnt=0;
		F(j,1,n) if(j!=i){
			k[++cnt]=atan2(x[j]-x[i],y[j]-y[i]);
		}
		std::sort(k+1,k+cnt+1);
		double t;
		t=k[1]-k[cnt]+PI+PI;
		if(t>=PI) {printf("%.15lf\n",(t-PI)/(PI+PI)); continue;}
		bool ok=0;
		F(j,1,cnt-1){
			t=k[j+1]-k[j];
			if(t>=PI) {printf("%.15lf\n",(t-PI)/(PI+PI)); ok=1; break;}
		} if(!ok) printf("%.15lf\n",0.);
	}
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            int min = 1000;
            for (int i = 0; i < str.Length; i++)
            {
                if (i + 2 == str.Length)
                {
                    break;
                }
                int a = int.Parse(str.Substring(i,3));
                int diff = Math.Abs(753 - a);
                if(diff <= min){
                    min = diff;
                }
            }
            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<" "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

void cp()
{
    int n, m;
    ll k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    for(ll &x : a)
        cin >> x;
    for(ll &x : b)
        cin >> x;
    // reverse(all(a));
    // reverse(all(b));
    for(int i = 1; i < n; i++)
        a[i] += a[i - 1];
    for(int i = 1; i < m; i++)
        b[i] += b[i - 1];


    int total = 0;
    for(int i = 0; i < n; i++)
        if(a[i] <= k)
            total = i + 1;
    for(int i = 0; i < n; i++)
    {
        //read [0, i] books from top of A
        int read_a = i + 1;
        ll time_a = a[i];
        if(time_a > k)
            break;

        ll left = k - time_a;

        int lo = 0, hi = m - 1;
        int pos = -1;
        while(lo <= hi)
        {
            int mid = (lo + hi) / 2;
            if(b[mid] <= left)
                pos = mid, lo = mid + 1;
            else
                hi = mid - 1;
        }
        if(pos == -1)
            continue;

        int read_b = pos + 1;
        // cout << i << ": " << read_a << " " << read_b;
        total = max(total, read_a + read_b);
    }
    for(int i = 0; i < m; i++)
        if(b[i] <= k)
            total = max(total, i + 1);
    for(int i = 0; i < m; i++)
    {
        //read [0, i] books from top of B
        int read_b = i + 1;
        ll time_b = b[i];
        if(time_b > k)
            break;

        ll left = k - time_b;

        int lo = 0, hi = n - 1;
        int pos = -1;
        while(lo <= hi)
        {
            int mid = (lo + hi) / 2;
            if(a[mid] <= left)
                pos = mid, lo = mid + 1;
            else
                hi = mid - 1;
        }
        if(pos == -1)
            continue;

        int read_a = pos + 1;
        // cout << i << ": " << read_a << " " << read_b;
        total = max(total, read_a + read_b);
    }

    cout << total;
}

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

Measured memory_bytes: 6340
<?php

$n = trim(fgets(STDIN));
$b = explode(' ', trim(fgets(STDIN)));

$ans = $b[0] + $b[count($b)-1];

for($i=$n-2; $i>=1; $i--){
  $ans += min($b[$i], $b[$i-1]);
}

echo $ans;
  
?>

Measured memory_bytes: 4604
//============================================================================
// Name        : ITP_1_6_D.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;

int main() {
	vector<vector<int> > matrix;
	vector<int> vec;
	int N,M,ans;
	cin >> N >> M;
	matrix.resize(N);
	for(int i=0;i<N;++i){
		matrix[i].resize(M);
	}
	vec.resize(M);
	for(int i=0;i<N;++i) {
		for(int j=0;j<M;++j) {
			scanf("%d",&matrix[i][j]);
		}
	}
	for(int i=0;i<M;++i) {
		scanf("%d",&vec[i]);
	}
	for(int i=0;i<N;++i) {
		ans=0;
		for(int j=0;j<M;j++) {
			ans+=matrix[i][j]*vec[j];
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 3236
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**7)
inf = float('inf')
mod = 10**9+7
ans = 0 ;count = 0 ;pro = 1


a,b,c,d=map(int,input().split())
if a+b-c-d>0:
    print("Left")
if a+b-c-d==0:
    print("Balanced")
if a+b-c-d<0:
    print("Right")



Measured memory_bytes: 38512
#include<stdio.h>
#define max 100000
#define sen 2000000000

struct Card{
  char s;
  int v;
};

struct Card L[max/2+2], R[max/2+2];

void merge(struct Card A[], int n, int left, int mid, int right){
  int i, j, k;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0 ; i<n1 ; i++)L[i]=A[left+i];
  for(i=0 ; i<n2 ; i++)R[i]=A[mid+i];
  L[n1].v=R[n2].v=sen;
  i=j=0;
  for(k=left ; k<right ; k++){
    if(L[i].v<=R[j].v){
      A[k]=L[i++];
    }else{
      A[k]=R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int partition(struct Card A[], int n, int p, int r){
  int i, j;
  struct Card t, x;
  x=A[r];
  i=p-1;
  for(j=p ; j<r ; j++){
    if(A[j].v<=x.v){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r){
  int q;
  if(p<r){
    q=partition(A, n, p, r);
    quickSort(A, n, p, q-1);
    quickSort(A, n, q+1, r);
  }
}

int main(){
  int n, i, v;
  struct Card A[max], B[max];
  char S[10];
  int sta=1;
  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    scanf("%s%d",S, &v);
    A[i].s=B[i].s=S[0];
    A[i].v=B[i].v=v;
  }
  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n-1);
  for(i=0 ; i<n ; i++){
    if(A[i].s!=B[i].s)sta=0;
  }
  if(sta==1)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0 ; i<n ; i++){
    printf("%c %d\n",B[i].s, B[i].v);
  }
  return 0;
}


Measured memory_bytes: 4028
N = input().split()
l = [1, 9, 7, 4]
ls = [int(i) for i in l]

j = 0

for i in N:
    if(int(i) in ls):
        ls.remove(int(i))
    else:
        j = 1

if(j == 0):
    print("YES")

if(j == 1):
    print("NO")



Measured memory_bytes: 3060
import bisect
s = input()
t = input()
sub = s+s
dp = []
for i in range(len(s)):
    d = [10**15]*26
    dp.append(d)
index = [[] for i in range(26)]
for i in range(len(sub)):
    index[ord(sub[i])-97].append(i)
for i in range(len(s)):
    cur = s[i]
    for j in range(26):
        if len(index[j]) != 0:
            k = bisect.bisect_right(index[j], i)
            dp[i][j] = index[j][k]-i
if s[0] == t[0]:
    ans = 1
else:
    ans = dp[0][ord(t[0])-97]+1
if dp[0][ord(t[0])-97] != 10**15 and dp[0][ord(t[0])-97] >= len(s):
    next = dp[0][ord(t[0])-97]-len(s)
else:
    next = dp[0][ord(t[0])-97]
if next == 10**15:
    print(-1)
    exit()
else:
    flag = True
for i in range(1,len(t)):
    cur = next
    if dp[cur][ord(t[i])-97] == 10**15:
        flag = False
        break
    else:
        ans += dp[cur][ord(t[i])-97]
        if cur + dp[cur][ord(t[i])-97] >= len(s):
            next = cur + dp[cur][ord(t[i])-97] - len(s)
        else:
            next = cur + dp[cur][ord(t[i])-97]
if flag:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 84700
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(30);
    int c,i;
    string s,t;
    cin>>s;
    cin>>t;
    c=0;
    for(i=0;i<3;i++){
        if(s[i]==t[i]){
            c=c+1;
        }
    }
    cout<<c;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
from collections import defaultdict
INF = float("inf")


def yes():
    print("YES")  # type: str


def no():
    print("NO")  # type: str


class UnionFind(object):

    def __init__(self, N):
        self.tree = list(range(N))

    def root(self, i):
        if self.tree[i] == i:
            return i
        else:
            self.tree[i] = self.root(self.tree[i])
            return self.tree[i]

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

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            self.tree[x] = y


def main():

    N, M = map(int, input().split())
    L = [0]*N
    lang_leader = defaultdict(int)
    for i in range(N):
        K, *L[i] = list(map(int, input().split()))
    # 前Nは人
    uf = UnionFind(N+1)
    for i in range(N):
        for l in L[i]:
            if lang_leader[l] == 0:
                lang_leader[l] = i+1
            else:
                uf.unite(i, lang_leader[l]-1)

    # print(uf.tree)
    # 人はすべて同じグループであるか
    flag = True
    for i in range(N):
        if not uf.same(0, i):
            flag = False
            break
    if flag:
        yes()
    else:
        no()

    pass


if __name__ == '__main__':
    main()


Measured memory_bytes: 87200
#include<stdio.h>
int main(void){
    int H,W;
    int h,w;
    while(scanf("%d %d",&H,&W)==2){
        if(H==0 && W==0) break;
        for(h=0; h<H; h++){
            if(h%2==0){
            for(w=0; w<W; w++){
                if(w%2==0)
                printf("#");
                else
                printf(".");
            }
        }
        else{
            if(h%2==1){
            for(w=0; w<W; w++){
                if(w%2==0)
                printf(".");
                else
                printf("#");
            }
            }
        }
        printf("\n");
        }
        printf("\n");
        }
    return 0;
}


Measured memory_bytes: 2052
#include<stdio.h>
int main(){
    int a,b,k;
    int i,j=0,tmp;
    int common[101];
    scanf("%d%d%d",&a,&b,&k);
    tmp=a;
    if(a>b)tmp=b;
    for(i=tmp;i>=1;i--){
        if(a%i==0&&b%i==0){
            common[j]=i;
            j++;
        }
    }
    printf("%d\n",common[k-1]);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

int main(void){
	int N, K;
	cin >> N >> K;

	if(N%K==0) cout << '0' << '\n';
	else cout << '1' << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string S;
    cin >> S;
    S[3] = '8';

    cout << S << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    final String LINE_SPR = System.getProperty("line.separator");
    final int BIG_MOD = 1000000007;

    void run() throws Exception {
        for(int i = 1; i <= 9; i++) 
            for(int j = 1; j <= 9; j++) 
                System.out.println(i + "x" + j + "=" + (i * j));
    }


    /*
     * Templates
     */
    void dumpObjArr(Object[] arr, int n) {
        for(int i = 0; i < n; i++) {
            System.out.print(arr[i]);
            if(i < n - 1)
                System.out.print(" ");
        }
        System.out.println("");
    }

    void dumpObjArr2(Object[][] arr, int m, int n) {
        for(int j = 0; j < m; j++) 
            dumpObjArr(arr[j], n);
    }

    int ni() throws Exception {
        return Integer.parseInt(br.readLine().trim());
    }

    long nl() throws Exception {
        return Long.parseLong(br.readLine().trim());
    }

    String ns() throws Exception {
        return br.readLine();
    }

    boolean isPrime(int n) {
        for(int i=2;i<n;i++) {
            if(n%i==0)
                return false;
        }
        return true;
    }

    int getPrime(int n) {
        List<Integer> primes = new ArrayList<Integer>();
        primes.add(2);
        int count = 1;

        int x = 1;
        while(primes.size() < n) {
            x+=2;
            int m = (int)Math.sqrt(x);
            for(int p : primes) {
                if(p > m) {
                    primes.add(x);
                    break;
                }

                if(x % p == 0) 
                    break;
            }
        }

        return primes.get(primes.size() - 1);
    }

    void gcjPrint(String str, int t) {
        System.out.println("Case #" + t + ": " + str);
    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
}

Measured memory_bytes: 15032
n = int(input())
a = list(map(int,input().split()))
mi = a[0]
mii = 1
ma = a[0]
mai = 1
for i in range(n):
  if a[i] > ma:
    ma = a[i]
    mai = i+1
  if a[i] < mi:
    mi = a[i]
    mii = i+1
if mi >= 0:
  print(n-1)
  for i in range(1,n):
    print(i,i+1)
elif ma <= 0:
  print(n-1)
  for i in range(n,1,-1):
    print(i,i-1)
elif abs(ma) >= abs(mi):
  print(n*2-1)
  for i in range(n):
    print(mai,i+1)
  for i in range(1,n):
    print(i,i+1)
else:
  print(n*2-1)
  for i in range(n):
    print(mii,i+1)
  for i in range(n,1,-1):
    print(i,i-1)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int debt = 100000;
		for (int i = 0; i < n; i++) {
			debt *= 1.05;
			if (debt % 1000 > 0) {
				debt = (int)(debt / 1000) * 1000  + 1000;
				//System.out.println(debt);
			}
		}
		
		System.out.println(debt);
	}
}

Measured memory_bytes: 17160
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <unordered_map>
#include <map>
#include <set>
#include <unordered_set>
#include <sstream>
typedef long long ll;
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    //for writing to files
    //freopen('input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int N, L;
    cin >> N >> L;
    vector<string> arr;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        arr.PB(s);
    }
    sort(arr.begin(), arr.end());
    for (auto x : arr) {
        cout << x;
    }

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	string sent, cp;
	int num;
	cin >> num;
	cin.ignore();
	for(int i = 0; i < num; i++)
	{
		getline(cin, sent);

		for(int j = 0; j < 27; j++)
		{
			for(int k = 0; k < 27; k++)
			{
				cp = sent;

				for(int l = 0; l < sent.size(); l++)
				{
					if(islower(cp[l]))
					{
						cp[l] = (j*(cp[l] - 97)+k) % 26;
						cp[l] += 97;
					}
				}

				if(cp.find("that") != string::npos)
				{
					goto ending;
				}
				else if(cp.find("this") != string::npos)
				{
					goto ending;
				}
			}
		}
ending:;
	   cout << cp << endl;
	}
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=200010;
int main(){
	ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	long long i,j,n,best=0,w[N],cap,a,b;
	cin>>n>>cap;
	memset(w,0,cap+1);
	while(n--){
		cin>>a>>b;
		for(i=cap;i>=a;--i) w[i]=max(w[i],w[i-a]+b);
	}
	for(i=1;i<=cap;++i){
		//cout<<w[i]<<" ";
		best=max(best,w[i]);
	}
	cout<<best;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  int count = 0;
  
 
    int oneNum = 0;
    int tenNum = 0;
    int hundredNum = 0;
    int thousandNum = 0;
    int tThousandNum = 0;
   
  for (int i = 0; i < 10; i++) {
    tThousandNum = i * 10000;
    oneNum = i;
    for (int j = 0; j < 10; j++) {
      hundredNum = j * 100;
      for (int k = 0; k < 10; k++) {
        thousandNum = k * 1000;
        tenNum = k * 10;
        
        int num = tThousandNum + thousandNum + hundredNum + tenNum + oneNum;
        if (A <= num && num <= B) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3592
from collections import deque
H,W=map(int,input().split())
white=0
s=[]
for y in range(H):
    line=input()
    white+=line.count('.')
    s.append(list(line))

q = deque([(0,0,1)])
q_append=q.append
q_popleft=q.popleft
while q:
    x,y,l=q_popleft()
    if s[y][x]!='.':
        continue
    if x==W-1 and y==H-1:
        print(white-l)
        break
    s[y][x]='*'
    for d in [(1,0),(0,1),(-1,0),(0,-1)]:
        nx, ny=(x+d[0],y+d[1])
        if 0<=nx<W and 0<=ny<H:
            q_append((nx,ny,l+1))
else:
    print(-1)
    


Measured memory_bytes: 40048
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define continue continue
#define break break
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;


int main(void){
	int a, b; cin >> a >> b;
	if(a<10 && b<10) cout << a*b << endl;
	else cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 256
from math import sqrt

def f(x):
    divisors = [[], []]
    for i in range(1, int(sqrt(x))+1):
        if x % i == 0:
            divisors[0].append(i)
            if i * i != x:
                divisors[1].append(x//i)
    return divisors[0] + divisors[1][::-1]

n, m = map(int, input().split())
for i in f(m):
    if n <= i:
        print(m//i)
        exit()

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

const int MAX = 1e2;
int a[MAX], b[MAX], n, mx = 0, k;

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i) {
		cin >> b[i];
		k += b[i];
	}
	k += a[0];
	mx = k;
	for (int i = 1; i < n; ++i) {
		k += a[i] - b[i - 1];
		if (k > mx) mx = k;
	}
	cout << mx;
}

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

const int Maxn = 22;

int n;
int p[Maxn];
int res;

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &p[i]);
    for (int i = 2; i < n; i++)
        if (p[i - 1] < p[i] && p[i] < p[i + 1] ||
            p[i - 1] > p[i] && p[i] > p[i + 1])
            res++;
    printf("%d\n", res);
    return 0;
}


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

#define N 500

int n, m, q;
int cnt[N+2][N+2];

int main()
{
	cin >> n >> m >> q;
	for( int i = 0; i < m; i++ ) {
		int l, r;
		cin >> l >> r;
		cnt[l][r]++;
	}

	for( int i = 1; i <= n; i++ ) {
		for( int j = 1; j <= n; j++ ) {
			cnt[i][j] += cnt[i][j - 1];
		}
	}

	for( int i = n; i >= 1; i-- ) {
		for( int j = 1; j <= n; j++ ) {
			cnt[i][j] += cnt[i + 1][j];
		}
	}

	for( int i = 0; i < q; i++ ) {
		int p, q;
		cin >> p >> q;
		int ans = cnt[p][q];

		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 1920
import java.io.*
import java.util.*

fun solve(N: Long, K: Long){
    println(if(N%K ==0L) 0 else 1)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    val K = sc.next().toLong()
    solve(N, K)
}



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

int main(){
  int p1,p2,p3;
  cin>>p1>>p2>>p3;
  int lowPasta;
  if(p1<=p2){
    if(p1<=p3){
      lowPasta=p1;
    }else{
      lowPasta=p3;
     }
  }else{
    if(p2<=p3){
       lowPasta=p2;
    }else{
       lowPasta=p3;
     }
  }

  int j1,j2;
  cin>>j1>>j2;
  int lowJuice;
  if(j1<=j2){
     lowJuice=j1;
   }else{
     lowJuice=j2;
   }

  cout<<lowPasta+lowJuice-50<<'\n';
  return 0;
}

Measured memory_bytes: 1160
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)

int N;

int main(int, char *[])
{
    cin >> N;
    
    int sum = 0;
    for(int n = N; n; n /= 10)
    {
        const int rem = n % 10;
        sum += rem;
    }

    if(sum == 1 && N != 1)
        cout << 10 << endl;
    else
        cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 999999999999999
#define MOD 1000000007

void func()
{
    string s,t,temp;
    cin>>s>>t;
    for(char i='a';i<='z';i++){
        temp=s+i;
        if(temp==t){
            cout<<"Yes"<<"\n";
            return;
        }
    }
    cout<<"No"<<"\n";
}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif

    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define rfor(i, n) for (int i = n-1; i>=0; --i)
#define rmod(x, y) (((x%y)+y)%y)
using namespace std;
typedef vector<int>::iterator vit;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef long long ll;
const int MAXN = 1024;

//OPERATORS


//GLOBALS


//FUNCTIONS


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,w;
	cin >> n >> w;
	vector<ll> W(w+1,0);
	for(int i = 0; i<  n; i++){
		ll peso, precio; cin >> peso >> precio;
		for(int i = w-peso; i >= 0; i--){
			W[i+peso] = max(W[i+peso],W[i] + precio);
		}
	}
	ll mx = 0;
	for(int i = 0; i <= w; i++){
		mx = max(W[i],mx);
	}
	cout << mx << endl;



	return 0;
}


Measured memory_bytes: 1024
INF = float("inf")

N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = -INF
for s in range(N):
    ### STEP1
    cum = []
    i = P[s] - 1 #s-> i
    cum.append(C[i])
    while i != s:
        i = P[i] - 1
        cum.append(cum[-1] + C[i])
    

    # STEP2
    if K <= len(cum):
        #1週未満しかできない
        score = max(cum[:K])
    
    elif cum[-1] <= 0:
        #一周以上できるが、ループしたら損する場合
        score = max(cum)
    else:
        # K//Length - 1回だけループし、最後は最適に止まる
        score1 = cum[-1] * (K//len(cum) - 1)
        score1 += max(cum)

        #ループをK//length回だけループする場合
        score2 = cum[-1]*(K//len(cum))
        resi = K % len(cum) #残り進める回数
        if resi != 0:
            #まだ進めるなら
            score2 += max(0, max(cum[:resi]))
        score = max(score1, score2)
    
    ans = max(ans, score)

print(ans)


Measured memory_bytes: 80812
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  int n;
  cin >> n;
  map<ll, int> a;
  rep(i,n) {
    ll x;
    cin >> x;
    a[x]++;
  }
  int ans = 0;
  for(auto itr = a.begin(); itr != a.end(); itr++) {
    if (itr->first > itr->second) ans += itr->second;
    else ans += itr->second - itr->first;
  }
  cout << ans << endl;
 
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <memory.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <queue>
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
typedef long long LL;
typedef double D;

int main()
{
	ios::sync_with_stdio(0);
	int n, t, d = 0, nd = 0;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> t;
		if (t % 4)
			nd += t & 1;
		else
			d++;
	}
	if (d >= nd || (nd == d + 1 && n == d + nd))
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll,ll> pii;
///-------------------------

int gcd(int x,int y)
{
    while (x%y!=0)
    {
        int t=y;
        y=x%y;
        x=t;
    }
    return y;
}

int main()
{
    Phuong_; /// <3
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> da(n,0);
    vector<int> db(n,0);
    vector<int> dc(n,0);
    for(int i=0; i<n; ++i)
    {
        if (s[i]=='R') da[i]++; else
        if (s[i]=='B') db[i]++; else
        dc[i]++;
        if (i>0)
        {
            da[i]+=da[i-1];
            db[i]+=db[i-1];
            dc[i]+=dc[i-1];
        }
    }
    ll ans=0;
    for(int i=0; i<n; ++i)
        for(int j=i-1; j>=0; --j)
    {
        if (s[i]=='R')
        {
            int dis = i-j;
            if (s[j]=='R') continue;
            if (s[j]=='B')
            {
                int num=0;
                if ((i+dis)<n && s[i+dis]=='G') num=-1;
                ans+= dc[n-1]- dc[i] + num;
            } else
            {
                int num=0;
                if ((i+dis)<n && s[i+dis]=='B') num=-1;
                ans+= db[n-1]- db[i] + num;
            }
        } else if (s[i]=='B')
        {
            int dis = i-j;
            if (s[j]=='B') continue;
            if (s[j]=='G')
            {
                int num=0;
                if ((i+dis)<n && s[i+dis]=='R') num=-1;
                ans+= da[n-1]- da[i] + num;
            } else
            {
                int num=0;
                if ((i+dis)<n && s[i+dis]=='G') num=-1;
                ans+= dc[n-1]- dc[i] + num;
            }
        } else
        {
            int dis = i-j;
            if (s[j]=='G') continue;
            if (s[j]=='R')
            {
                int num=0;
                if ((i+dis)<n && s[i+dis]=='B') num=-1;
                ans+= db[n-1]- db[i] + num;
            } else
            {
                int num=0;
                if ((i+dis)<n && s[i+dis]=='R') num=-1;
                ans+= da[n-1]- da[i] + num;
            }
        }
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 3656
import scala.io.StdIn.{readInt, readLine}

case class Shiritori(words: List[String]) {

  @scala.annotation.tailrec
  private def recursive(before: Char, residue: List[String]): Boolean =
    residue match {
      case Nil => true
      case h :: t if before == h.head => recursive(h.last, t)
      case _ => false
    }

  def isSatisfy: Boolean =
    recursive(words.head.last, words.tail) &&
      words.toSet.size == words.size

}

object Main extends App {

  val n = readInt
  val words = (1 to n) map ( _ => readLine.trim) toList

  if (Shiritori(words).isSatisfy) println("Yes") else println("No")

}


Measured memory_bytes: 27200
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <bitset>
#include <map>

#define rep(i, l, r) for(int i=l; i<=r; i++)
#define dow(i, l, r) for(int i=l; i>=r; i--)
#define clr(x, c) memset(x, c, sizeof(x))
#define travel(x) for(edge *p=fir[x]; p; p=p->n)
#define all(x) (x).begin,(x).end
#define pb push_back
#define fi first
#define se second
#define l(x) Left[x]
#define r(x) Right[x]
#define lowbit(x) (x&-x)

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,int> Pli;
typedef long double ld;
typedef unsigned long long ull;

inline int read()
{
	int x=0; bool f=0; char ch=getchar();
	while (ch<'0' || '9'<ch) f|=ch=='-', ch=getchar();
	while ('0'<=ch && ch<='9') x=x*10+ch-'0', ch=getchar();
	return f?-x:x;
}

/* struct num
{
	int L, a[maxn];
	void input()
	{
		char s[maxn]; clr(s,0); scanf("%s", s);
		L=strlen(s);
		rep(i, 0, L-1) a[i]=s[L-1-i]-'0';
	}
	void output()
	{
		char s[maxn]; clr(s,0);
		rep(i, 0, L-1) s[i]=a[L-1-i]+'0';
		printf("%s", s);
	}
	void dec1()
	{
		a[0]--; 
		rep(i, 0, L-1) if (a[i]<0) a[i]+=10, a[i+1]--;
		if (a[L-1]==0) L--;
	}
	void div2()
	{
		dow(i, L-1, 1) a[i-1]+=(a[i]%2?10:0), a[i]/=2; a[0]/=2;
		if (a[L-1]==0) L--;
	}
	void mult2()
	{
		rep(i, 0, L-1) a[i]*=2;
		rep(i, 0, L-1) if (a[i]>9) a[i]-=10, a[i+1]++;
		if (a[L]) L++;
	}
}; */



#define maxn 200009

int n, A[maxn], B[maxn];

int main()
{
	n=read();
	rep(i, 1, n) A[i]=read();
	for(int i=n,a=1,b=n,c=0; i>=1; i--,c^=1) if (c) B[b--]=A[i]; else B[a++]=A[i];
	rep(i, 1, n) printf("%d ", B[i]);
	return 0;
}

Measured memory_bytes: 3712
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 50;
LL dp[N + 5][N + 5][N * N + 5];
LL arr[N + 5];
int m;

LL solve(int idx,int pck, int tot) {
	if(idx == 0) {
		if(pck != 0) return m * pck == tot;
		return 0;
	}
	LL &res = dp[idx][pck][tot];
	if(res != -1) return res;
	res = solve(idx - 1, pck, tot) + solve(idx - 1, pck + 1, tot + arr[idx]);
	return res;
}

void hora(int tc) {
	int n;
	cin>>n>>m;
	for(int i = 1;i <= n;i++) cin>>arr[i];
	memset(dp, -1, sizeof dp);
	cout<<solve(n, 0, 0)<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}




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

int main()
{
    int n, l;
    cin >> n >> l;
    
    vector<string> s(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> s[i];
    }
    
    sort(s.begin(), s.end());
    
    for(int i = 0; i < n; ++i)
    {
        cout << s[i];
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200005
#define ll long long
#define pb push_back
using namespace std; 
int fa[N],n;
ll ans,a[N],m;
struct node
{
	int L,R;
	ll val;
	node(ll x,int y,int z){val=x,L=y,R=z;}
	bool operator < (const node &x) const
	{
		if(val!=x.val)return val<x.val;
		if(L!=x.L)return L<x.L;
		return R<x.R;
	}
};
int search(int x)
{
	if(fa[x]==x)return x;
	return fa[x]=search(fa[x]);
}
vector<node> v;
void solve(int l,int r)
{
	if(l==r)return;
	int mid=(l+r)>>1,min_l,min_r;
	ll mn=-1;
	for(int i=l;i<=mid;i++)
	{
		ll value=a[i]-m*(ll)i;
		if(mn==-1||mn>value)
		min_l=i,mn=value;
	}
	mn=-1;
	for(int i=mid+1;i<=r;i++)
	{
		ll value=a[i]+m*(ll)i;
		if(mn==-1||mn>value)
		min_r=i,mn=value;
		ll tmp=a[i]+a[min_l]+m*(ll)(i-min_l);
		v.pb(node(tmp,min_l,i));
	}
	for(int i=l;i<=mid;i++)
	{
		ll tmp=a[i]+a[min_r]+m*(ll)(min_r-i);
		v.pb(node(tmp,i,min_r));
	}
	solve(l,mid);
	solve(mid+1,r);
}
int main()
{
    for(int i=0;i<N;i++)
    fa[i]=i;
	scanf("%d%lld",&n,&m);
	for(int i=0;i<n;i++)
	scanf("%lld",a+i);
	solve(0,n-1);
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
	{
		
		int x=search(v[i].L),y=search(v[i].R);
		if(x==y)continue;
		ans+=v[i].val;
		fa[x]=y;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 70112
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char[] ac = S.toCharArray();
    Set<Character> C = new HashSet<>();

    for(char c: ac) {
    	C.add(c);
    }
    String ans = "no";
    if (C.size() == ac.length) ans = "yes";
    System.out.println(ans);

  }
}

Measured memory_bytes: 35680
/* Coached by rainboy and Dukkha */
#include <stdio.h>

int main() {
	int n, ans;

	scanf("%d", &n);
	ans = 0;
	while (n--) {
		int a;

		scanf("%d", &a);
		ans += a - 1;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

ll f(ll k, vector<ll>& a, int n) {
  ll ans=0;
  rep(i,n) {
    ans+=a[i]^k;
  }
  return ans;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  ll K;
  cin>>n>>K;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  ll ans=0;
  rep(i,41) {
    if(!(K&(1LL<<i)))
      continue;
    ll tmp=0;
    rep(j,41) {
      ll mask=1LL<<j;
      ll one=0;
      rep(k,n) {
        if(mask&a[k])
          one++;
      }
      if(i>j) {
        tmp+=max(one,n-one)*mask;
      } else if(j==i) {
        tmp+=one*mask;
      } else { // j>i
        if(mask&K) {
          tmp+=(n-one)*mask;
        } else {
          tmp+=one*mask;
        }
      }
    }
    ans=max(ans,tmp);
  }
  cout << max(ans,f(K,a,n)) << endl;
  return 0;
}


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

public class Main{
	public static void main (String[] args) {
		Scanner cin = new Scanner(System.in);
		int n = cin.nextInt();
		int best = 0;
		int last = cin.nextInt();
		int cur = 0;
		for(int i=1;i<n;i++) {
		    int next = cin.nextInt();
		    if(last >= next) {
		        cur++;
		    }
		    else {
		        cur = 0;
		    }
		    last = next;
		    best = Math.max(best, cur);
		}
		System.out.println(best);
	}
}

Measured memory_bytes: 46792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Msolutions2019
{
    class D
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            HashSet<int>[] graph = new HashSet<int>[n];
            for (int i = 0; i < n; i++) graph[i] = new HashSet<int>();
            for(int i = 0; i < n - 1; i++)
            {
                int[] ab = ReadInts();
                graph[ab[0] - 1].Add(ab[1] - 1);
                graph[ab[1] - 1].Add(ab[0] - 1);
            }
            long[] cs = ReadLongs();
            Array.Sort(cs);
            int now = 0;
            long score = 0;
            Queue<int> queue = new Queue<int>();
            for(int i = 0; i < n; i++)
            {
                if (graph[i].Count == 1) queue.Enqueue(i);
            }
            long[] point = new long[n];
            for (int i = 0; i < n; i++) point[i] = -1;
            while (queue.Count > 0)
            {
                int val = queue.Dequeue();
                if (point[val]>=0) continue;

                if(now<n-1) score += cs[now];
                point[val] = cs[now];
                now++;
                if (now == n) break;

                foreach(int i in graph[val])
                {
                    graph[i].Remove(val);
                    if (graph[i].Count == 1) queue.Enqueue(i);
                }
            }
            WriteLine(score);
            for(int i = 0; i < n; i++)
            {
                Write(point[i]);
                if (i < n - 1) Write(" ");
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 22460
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

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

  static int dp[3001][3001];
  fill(dp[0],dp[3000]+3000,-(1<<30));
  function< int(int,int) > rec =
  [&](int l,int r){
    if(l > r) return 0LL;
    if(dp[l][r] != -(1<<30)) return dp[l][r];
    int res = max(a[l] - rec(l+1,r),a[r] - rec(l,r-1));
    return dp[l][r] = res;
  };
  cout << rec(0,n-1) << endl;

  return 0;
}


Measured memory_bytes: 70912
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		long ans = 0;
		for (long b = K + 1; b <= N; ++b) {
			if ((N - b + 1) / b * b + b > N - K) {
				ans += (N - b + 1) / b * (N - K - (N - b + 1) + 1);
			} else {
				long tmp = (N - b + 1) / b * b + b;
				ans += (N - b + 1) / b * (tmp - (N - b + 1));
				ans += ((N - b + 1) / b + 1) * (N - K - tmp + 1);
			}
			ans += b - K;
			if (K == 0)
				--ans;
		}
		System.out.println(ans);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 21332
// ------------------------------------
// Date:2018/ 3/ 6
// Problem:ABC 081 PlacingMarbles a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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


  string S;
  cin >> S;
  int cnt = 0;
  REP(i, S.size()) {
    if (S[i] == '1') ++cnt;
  }
  printf("%d\n", cnt);
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif


int main ()
{
    #ifdef Lollipop
        //freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    int n;
    cin >> n;
    bool flag = true;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        if (x & 1){
            continue;
        }
        else{
            if (x % 3 == 0 || x % 5 == 0){
                continue;
            }
            else{
                flag = false;
            }
        }
    }
    if (flag){
        cout << "APPROVED\n";
    }
    else{
        cout << "DENIED\n";
    }
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007 /*998244353*/;
int main(){
    ll n, m, x;
    cin >> n >> x >> m;
    vector<ll> rem;
    rem.push_back(x % m);
    vector<bool> bl(m);
    ll cur;
    ll stt;
    while(true){
        ll num = rem[rem.size() - 1];
        bl[num] = true;
        num = (num * num) % m;
        if(bl[num]){
            cur = num;
            break;
        }
        else{
            rem.push_back(num);
        }
    }
    for (int i = 0; i < rem.size(); i++)
    {
        if(cur == rem[i])
            stt = i;
    }
    if(n <= rem.size()){
        ll total = x;
        for (int i = 1; i < n; i++){
            total += rem[i];
        }
        cout << total << "\n";
    }
    else{
        ll ls = rem.size() - stt;
        ll total = x;
        for (int i = 1; i < rem.size(); i++){
            total += rem[i];
        }
        n -= rem.size();
        ll div = n / ls;
        ll ama = n % ls;
        ll tmp = 0;
        for (int i = stt; i < rem.size(); i++)
            tmp += rem[i];
        total += div * tmp;
        for (int i = 0; i < ama; i++){
            total += rem[stt + i];
        }
        cout << total << "\n";
    }
}

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

using namespace std;

using ll = long long;
#define long long long

int main(void) {
    ll n, x;
    cin >> n >> x;
    vector<ll> l(n);
    for(auto &e: l) cin >> e;
    for(ll i=1; i<n; i++)
        l[i] += l[i-1];
    cout << 1 + (upper_bound(l.begin(), l.end(), x) - l.begin()) << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
#define mod (ll)(1e9+7)
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,c,x,k,ans=0;
    cin>>n>>m>>c;
    ll arr[m];
    for(ll i=0;i<m;i++)cin>>arr[i];
    while(n--){
        k=c;
        for(ll i=0;i<m;i++){
            cin>>x;
            k+=x*arr[i];
        }
        if(k>0)ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int main() {
	int a, b, h;
	cin >> a;
	cin >> b;
	cin >> h;

	int s = (a + b) * h / 2;

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ld pi = (acos(-1));
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int n; cin >> n;
  vector<pair<ll,ll>> a(n);
  rep(i,0,n) cin >> a[i].first ,a[i].second=i;
  sort(rALL(a));
  vector<vector<ll>> dp(n+1, vector<ll>(n+1,0));
  rep(i,0,n){
    rep(j,0,n-i){
      chmax(dp[i+1][j],dp[i][j]+a[i+j].first*(a[i+j].second-i));
      chmax(dp[i][j+1],dp[i][j]+a[i+j].first*((n-1-j)-a[i+j].second));
    }
  }
  ll ans=0;
  rep(i,0,n+1) chmax(ans,dp[i][n-i]);
  cout << ans << endl; 
}

Measured memory_bytes: 34616