akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int n,m,k,x1,x2,y11,y2;
int dx[5] = {-1,1,0,0};
int dy[5] = {0,0,-1,1};

int main()
{
    fastio();
    cin>>n>>m>>k;
    vector<vector<char>> mp(n,vector<char>(m));
    vector<vector<int>> dis(n,vector<int>(m,inf));
    cin>>x1>>y11>>x2>>y2;
    rep(i,0,n-1) rep(j,0,m-1) cin>>mp[i][j];
    x1--,y11--,x2--,y2--;
    queue<pii_> q;
    q.push(mp_(x1,y11));
    dis[x1][y11] = 0;
    while(!q.empty()){
        int x=q.front().fi,y=q.front().se;
        q.pop();
        rep(i,0,3){
            rep(j,1,k){
                int nx=x+j*dx[i],ny=y+j*dy[i];
                if(nx>=0&&nx<n&&ny>=0&&ny<m&&mp[nx][ny]=='.'&&(dis[nx][ny]==inf||dis[nx][ny]==dis[x][y]+1)){
                    if(dis[nx][ny]==inf){
                        dis[nx][ny] = dis[x][y]+1;
                        q.push(mp_(nx,ny));
                    }
                }else break;
            }
        }
    }
    if(dis[x2][y2]==inf) cout<<-1<<endl;
    else cout<<dis[x2][y2]<<endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

int main() {
    string s,t;
    cin>>s>>t;
    int a=0;
    for(int i=0;i<s.size();++i) {
        if(s[i] != t[i]) ++a;
    }
    cout<<a<<endl;
}

Measured memory_bytes: 3804
import java.io.BufferedReader
import java.io.InputStreamReader

@Suppress("LocalVariableName")
fun main(a: Array<String>) {
    val reader = BufferedReader(InputStreamReader(System.`in`))
    val N = reader.readLine().toInt() - 1
    val args = reader.readLine().split(" ")
    val A = (0..N).map { args[it].toInt() }.filter { it % 2 == 0 }
    if (A.filterNot { it % 5 == 0 || it % 3 == 0 }.isEmpty()) {
        println("APPROVED")
    } else {
        println("DENIED")
    }
}


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

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



Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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 n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    rep(i,n) {
        if(a[i]%2==1 && (i+1)%2==1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
int C[12];
int A[12][12];
int skill[12];
int main(){
  int N;
  int M;
  int X;
  cin >> N >> M >> X;

  for(int i = 0; i < N; i++){
    cin >> C[i];
    for(int j = 0; j < M; j++){
      cin >> A[i][j];
    }
  }

  int best_cost = INT_MAX;
  for(int bit_set = 0; bit_set < (1 << N); bit_set ++){
    for(int i = 0; i < M; i++){
      skill[i] = 0;
    }

    int cur_cost = 0;
    for(int i = 0; i < N; i++){
      if(((bit_set >> i) & 1) == 1){
        cur_cost += C[i];
        for(int  j= 0; j < M; j++){
          skill[j] += A[i][j];
        }
      }
    }
    bool valid = true;
    for(int i = 0; i < M; i++){
      if(skill[i] < X){
        valid = false;
        break;
      }
    }
    if(valid){
      best_cost = min(best_cost, cur_cost);
    }
  }
  
  if(best_cost == INT_MAX){
    cout << -1 << endl;
  } else {
    cout << best_cost << endl;
  }
  return 0;
}


Measured memory_bytes: 3636
import math

a,b,x=map(int,input().split())
S=x/a

if S <= a*b/2:
    ans = math.atan((b**2)/(2*S))
else:
    S = a*b - S
    ans = math.atan(S*2/(a**2))

ans = ans * 180/math.pi
print(ans)


Measured memory_bytes: 2940
let watch s =
  let h = s/(60*60) in
  let m = (s mod (60*60))/60 in
  let s = ((s mod (60*60)) mod 60) in
  Printf.printf "%d:%d:%d\n" h m s;;

let f s = Scanf.sscanf s "%d" watch ;;

f (read_line()) ;;



Measured memory_bytes: 2440
#include <bits/stdc++.h>
#include<algorithm>//next_permutation
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
 
 
int main (){
    string s;
    cin >> s;
    int n = s.size();
    int z =0,o;
    rep(i,n){
        if(s[i]=='0')z++;
    }
    o = n-z;
    cout << min(o,z)*2 <<endl;
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))

X = [a - i - 1 for i, a in enumerate(A)]
X.sort()
if N % 2 != 0:
    med = X[N // 2]
    ans = sum([abs(x - med) for x in X])
else:
    med1 = X[N // 2 - 1]
    med2 = X[N // 2]
    ans = min(sum([abs(x - med1) for x in X]), sum([abs(x - med2) for x in X]))
print(ans)


Measured memory_bytes: 27844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <math.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> B(N-1);
  for(int i = 0; i < N - 1; i++){
    cin >> B[i];
  }

  vector<int> A(N);
  A[0] = B[0];
  A[1] = B[0];
  for(int i = 1; i < N - 1; i++){
    A[i+1] = B[i];
    if(B[i] < B[i-1]){
      A[i] = B[i];
    }
  }
  unsigned long long ans = 0;
  for(int i = 0; i < N; i++){
    ans += A[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a[3],i,A,B;
	for(i=0;i<3;i++)
	{
		a[i]=i+1;
	}
	scanf("%d",&A);
	scanf("%d",&B);
	for(i=0;i<3;i++)
	{
		if(a[i]==A||a[i]==B)
		a[i]=0;
	}
	for(i=0;i<3;i++)
	{
		if(a[i]!=0)
		printf("%d",a[i]);
	}
	return 0;
 } 

Measured memory_bytes: 128
#=
E:
- Julia version:0.5.2
- Author: abap
- Date: 2020-01-12
=#
parseInt(x) = parse(BigInt, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
N = parseInt(readline())
A = parseMap(split(readline()))
x = lcm(A)
ans = 0
for i in A
	ans += x ÷ i
end
anser = ans % (10^9 + 7)
println(Int64(anser))


Measured memory_bytes: 153800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(){
  ll x,y;
  cin >> x >> y;
  ll count=0;
  while(x <= y){
    x*=2;
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import sys


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


def main():
    s = input()

    ans = [0]*len(s)
    now = "R"
    count = 0
    cp = 0
    for i in range(len(s)):
        if s[i] == now:
            count += 1
        else:
            now = s[i]
            if s[i] == "L":
                cp = i
            index = cp

            if count % 2 == 0:
                ans[index] += count//2
                ans[index-1] += count//2
            else:
                if s[i] == "L":
                    ans[index] += count//2
                    ans[index-1] += count//2+1
                else:
                    ans[index] += count//2+1
                    ans[index-1] += count//2
            count = 1

    index = cp

    if count % 2 == 0:
        ans[index] += count//2
        ans[index-1] += count//2
    else:
        ans[index] += count//2+1
        ans[index-1] += count//2

    print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 47676
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int t = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());

        double[] arr = new double[n]; //aとの差

        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(sc.next());
            double temp = t-arr[i]*0.006;
            arr[i] = Math.abs(a-temp);
        }
        int index = -1;
        double min = arr[0];
        for (int i = 0; i < n; i++) {
            if (min >= arr[i]){
                min = arr[i];
                index = i;
            }
        }
        System.out.println(index+1);
    }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
        int hen[] = new int[n]; 
        int big;
		for(int i = 0;i < n; i++){
          hen[i] = sc.nextInt();
        }
        Arrays.sort(hen);
        big = hen[n - 1];
        for(int i = 0;i < n - 1; i++){
          big -= hen[i];
        }
        if(big < 0){
        	System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35808
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

int main(void) {
  vector<int> v;
  for(int i=0; i<3; i++) {
    int x;
    cin>>x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  if(v[2]<v[0]+v[1] and v[0]==v[1] and v[2]==v[1])
    cout<<"Yes";
  else
    cout<<"No";
  cout<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <numeric>
#include <queue>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef vector<vector<char>> field_t;
typedef unsigned long long ull;
typedef pair<ll, ll> point_t;

int main()
{
    int x[5],ans;
    rep(i,5){
        cin >> x[i];
        if(x[i]==0){
             ans=1+i;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;
 
public class Main {
	public static void main (String[] args) {
		Scanner scan = new Scanner(System.in);
long h = scan.nextLong();
		
		long sum = 1;
		long x = 2;
		
		while (h != 0) {
			sum += x;
			x*=2;
			h/=2;
		}
		x/=2;
		sum -=x;
		
		System.out.println(sum);
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,k,q,m;
    vector<ll>v,u;
    cin>>n>>k>>q;
    for(ll i=0;i<n;i++)
    {
        v.push_back(k);
    }
    for(ll i=0;i<q;i++)
    {
        cin>>m;
        v[m-1]++;
    }
    for(ll i=0;i<n;i++)
    {
        if(v[i]>q)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1524
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    char a, b;
    cin >> a >> b ;
    //*/
    
    /*
    vector<int> a(3);
    cin >> a.at(0) >> a.at(1) >> a.at(2) ;
    
    sort(a.begin(), a.end());
    */
    
    //*
    if( a == b ){
        cout << "=" << endl;
    } else if (a > b){
        cout << ">" << endl;
    } else {
        cout << "<" << endl;
    }
    //*/
    
    //cout << b * 2 - a << endl;

    return 0; 
}


Measured memory_bytes: 3624
import java.util.Scanner;

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

        int a=sc.nextInt();
        int b=sc.nextInt();

        ans=(a+b)/2;

        System.out.println(ans);
    }
}


Measured memory_bytes: 26328
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int h, w;
  cin >> h >> w;
  int ans = min(h, w);
  if (h % 3 == 0 || w % 3 == 0) ans = 0;
  for (int i = 1; i < w; i++) {
    vector<int> a = {i * h, (w - i) * (h / 2), (w - i) * (h - h / 2)};
    sort(a.begin(), a.end());
    ans = min(ans, a[2] - a[0]);
  }
  for (int i = 1; i < h; i++) {
    vector<int> a = {i * w, (h - i) * (w / 2), (h - i) * (w - w / 2)};
    sort(a.begin(), a.end());
    ans = min(ans, a[2] - a[0]);
  }
  cout << ans << "\n";
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mincosttogo(int a[],int memo[],int st,int end)
{
  if(st>=end)
    return 0;
  if(memo[end]!=-1)
    return memo[end];
  int temp1=INT_MAX,temp2=INT_MAX;
  if(end>=1)
  temp1=mincosttogo(a,memo,st,end-1)+abs(a[end]-a[end-1]);
  if(end>=2)
  temp2=mincosttogo(a,memo,st,end-2)+abs(a[end]-a[end-2]);
  return memo[end]=min(temp1,temp2);
}
int main()
{
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++)
  cin >> a[i];
  int memo[n+1];
  for(int i=0;i<=n;i++)
    memo[i]=-1;
  cout << mincosttogo(a,memo,0,n-1) << endl;
  return 0;
}

Measured memory_bytes: 12108
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

signed main() {
  int N; cin >> N;
  int cnt = 0;
  REP(i, N) {
    int x, y; cin >> x >> y;
    if (x == y) {
      ++cnt;
    } else {
      cnt = 0;
    }
    if (cnt == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;

	string str(to_string(N));
	bool is_good(false);
	if (str[0] == str[1] && str[1] == str[2]) {
		is_good = true;
	}
	if (str[1] == str[2] && str[2] == str[3]) {
		is_good = true;
	}

	cout << ((is_good) ? "Yes" : "No") << endl;
	return 0;
}


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

int main()
{
  int n, S;
  while (cin >> n >> S) {
    if ((n|S) == 0)
      break;

    vector<int> r(n);
    for (int i = 0; i < n; ++i)
      cin >> r[i];
    sort(r.begin(), r.end());

    int ans = 0;
    for (int i = 0; i < n; ++i)
      ans += r.end() - upper_bound(r.begin()+i+1, r.end(), S-r[i]);

    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 940
using System;
using System.Collections.Generic;
using System.Linq;

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

            string S = Console.ReadLine();
            Console.WriteLine(S.Substring(0,3));
            Console.SetOut(sw);
            Console.Out.Flush();
        }

    }
}


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

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

using namespace std;

int main() {
  while(1){
    int n,m;
    cin>>n>>m;
    if(!n)break;
    vector<int> h(n);
    vector<int> w(m);
    REP(i,n)cin>>h[i];
    REP(i,m)cin>>w[i];
    vector<int> hs(n+1,0);
    vector<int> ws(m+1,0);
    partial_sum(begin(h),end(h),begin(hs)+1);
    partial_sum(begin(w),end(w),begin(ws)+1);
    vector<int> s1;
    vector<int> s2;
    REP(i,n+1){
      REP(j,i){
        s1.push_back(hs[i]-hs[j]);
      }
    }
    REP(i,m+1){
      REP(j,i){
        s2.push_back(ws[i]-ws[j]);
      }
    }
    sort(begin(s1),end(s1));
    int64_t sum = 0;
    for(int wd:s2){
      auto p=equal_range(begin(s1),end(s1),wd);
      sum += p.second - p.first;
    }
    cout<<sum<<endl;
  }
  return 0;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

from collections import deque

def main():
    mod=10**9+7
    N=I()
    a=LI()
    ans=deque()
    for i in range(N):
        if i%2==1:
            ans.append(a[i])
        else:
            ans.appendleft(a[i])
    if N%2==0:
        ans.reverse()
    print(' '.join(map(str, ans)))
    

main()


Measured memory_bytes: 121172
import sys

def spin(x):
    result=[]
    for i in x:
        result.append([-1*i[1],i[0]])
    return result
def rev(x):
    y=x.copy()
    y.reverse()
    a=y[0][0]
    b=y[0][1]
    for i in y:
        i[0]-=a
        i[1]-=b
    return y

def check(x):
    if x==line_original or spin(x)==line_original or spin(spin(x))==line_original or spin(spin(spin(x)))==line_original:
        return True
    else:
        return False



while True:
    n=int(input())
    if n==0:
        sys.exit()

    m=int(input())
    line_original=[[0,0]]
    a,b=[int(i) for i in input().split(" ")]
    for count in range(m-1):
        p,q=[int(i) for i in input().split(" ")]
        line_original.append([p-a,q-b])
    line_list=[]
    for loop in range(n):
        m=int(input())
        line=[[0,0]]
        a,b=[int(i) for i in input().split(" ")]
        for count in range(m-1):
            p,q=[int(i) for i in input().split(" ")]
            line.append([p-a,q-b])
        line_list.append(line)

    for i in range(n):
        if (check(line_list[i])==True) or (check(rev(line_list[i]))==True):
            print(i+1)
    print("+++++")
    

Measured memory_bytes: 7792
/******************************************
* AUTHOR : GURUTEJA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

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

}

  int main() {
    debug();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n,w;
    cin>>n>>w;

    if(w==1||n==1){
    	cout<<1<<endl;
    	return 0;
    }

    if(!(w&1) ){
    	cout<<(n)*(w/2)<<endl;
    }else{
    	long long int x;
    	if(n&1)
            x=(((n+1)/2)*((w+1)/2))+(((n-1)/2)*((w-1)/2));
        else
            x=((n/2)*((w+1)/2))+((n/2)*((w-1)/2));
        cout<<x<<endl;
    }
    return 0;
  }

Measured memory_bytes: 3652
s = input()
t = input()
ns = len(s)
nt = len(t)
ret = ns + 1
for i in range(ns - nt+ 1):
  tmp = 0
  for j in range(nt):
    if s[i + j] != t[j]:
      tmp += 1
  if ret > tmp:
    ret = tmp
    
print(ret)

Measured memory_bytes: 9052
L,R=map(int,input().split())
a=(L-1)//2019
b=L%2019
c=R//2019
d=R%2019
if a!=c:
  print("0")
else:
  if b>=d:
    d=d+2019
  f=(b*d)%2019
  for i in range(b,d):
    for j in range(i+1,d+1):
      e=(i*j)%2019
      if e<f:
        f=e
      j=j+1
    i=i+1
  print(f)
      

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

ll dp[105][100005];
ll sum[100005];
void solve(){
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    dp[0][0]=1;//dp[i][j]:i人目まで見たときに和をjにする方法の数
    rep(i,n){
        sum[0]=0;
        for(int j=1;j<=k+1;++j){
            sum[j]=(sum[j-1]+dp[i][j-1])%mod;//添え字の違いに注意
        }//sum[j]=dp[i][0]+dp[i][1]+....+dp[i][j-1] : 1個添え字を大きくしないと引き算が出来ない
        rep(j,k+1)dp[i+1][j]=(sum[j+1]-sum[max(0,j-a[i])]+mod)%mod;
    }
    cout<<dp[n][k]<<"\n";
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 79360
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
const int maxn = 10010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int n;
bool dp[maxn];
int s[maxn];
int sum = 0;
int main()
{
    //freopen("D:\\code\\text\\input.txt","r",stdin);
    //freopen("D:\\code\\text\\output.txt","w",stdout);
    n = readint();
    repd(i, 1, n)
    {
        s[i] = readint();
        sum += s[i];
    }
    if (sum % 10 != 0)
    {
        printf("%d\n", sum );
        return 0;
    }
    dp[0] = 1;
    repd(i, 1, n)
    {
        for (int j = sum; j >= s[i]; --j)
        {
            if (dp[j - s[i]])
            {
                dp[j] = 1;
            }
        }
    }
    int ans = 0;
    for (int j = sum; j >= 0; --j)
    {
        if (j % 10 == 0)
            continue;
        if (dp[j])
        {
            ans = j;
            break;
        }
    }
    printf("%d\n", ans );
    return 0;
}




Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int k,n;
int a[20];
int ans;
int main()
{
	scanf("%d%d", &n, &k);
	for(int i=0;i<k;i++)
		scanf("%d", &a[i]);
	ans=n;
	while(ans>=n)
	{
		bool flag=false;
		int temp=ans;
		for(int i=0;i<k;i++)
			if(temp%10==a[i])
				flag=true;
		while(temp)
		{
			for(int i=0;i<k;i++)
				if((temp%10)==a[i])
				{
					flag=true;
					break;
				}
			if(flag==true)
				break;
			temp/=10;
		}
		if(flag==true)
		{
			ans++; 
			continue;
		}
		printf("%d", ans);
		break;
	} 
	return 0; 
}  

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

#define ll             long long
#define sf             scanf
#define pf             printf
#define nl             printf("\n")
#define TEST           int Test;cin>>Test;for(int _t=1;_t<=Test;_t++)
#define si(n)          scanf("%d",&n)
#define inarr(a,i,n)   for(int i=0; i<n; i++) scanf("%d",&a[i])

using namespace std;



int main()
{
	string str;
	cin>>str;
	int cnt = 0;
	int mx = 0;
	for(int i=0; i<(int)str.size(); i++){
		if(str[i]=='R') cnt++;
		else{
			mx = max(mx,cnt);
			cnt = 0;
		}
	}
	mx = max(cnt,mx);
	pf("%d\n",mx);
	return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint n; cin >> n;
  vector<lint> a(n);
  lint sum = 0;
  lint mi = INF;
  for (int i = 0; i < n; i++) {
    cin >> a[i]; 
    sum += a[i];
    mi = min(mi, a[i]);
  }
  sort(ALL(a));

  string ans = "";
  if (n % 2 == 1) {
    ans = (sum % 2 == 0) ? "Second" : "First";
  } else {
    ans = (sum % 2 == 0 and mi % 2 == 0) ? "Second" : "First";
  }

  cout << ans << endl;

  return 0;
}



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

int main(){

	int n;
	vector<long long int> a, b, c, bc, ab;
    long long int ans=0;
  
  	cin>> n;

	a.resize(n);
	b.resize(n);
	c.resize(n);
	bc.resize(n);
	ab.resize(n);

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

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

    for(int i=0;i<n;i++){
    	auto itr=upper_bound(c.begin(), c.end(), b[i]);
    	bc[i]=c.end()-itr;
		//cout<< bc[i] <<endl;
    }
  	for(int i=n-2;i>=0;i--)	bc[i]+=bc[i+1];
  //for(int i=0;i<n;i++) cout<< bc[i] <<" ";
  //cout<< endl;

    for(int i=0;i<n;i++){
    	auto itr=upper_bound(b.begin(), b.end(), a[i]);
      	//cout<< itr-b.begin() << " ";
    	ans+=bc[itr-b.begin()];
      //cout<<bc[itr-b.begin()] <<endl;
    }
  
	cout<< ans <<endl;
  
    return 0;
}

Measured memory_bytes: 4224
//AtCoder Beginner Contest 073 A

#include<bits/stdc++.h>
using namespace std;
int MAXN = 10010;

int main(){
  int N;
	cin >> N;
  if ( N % 10 == 9 || N / 10 == 9 ){
    cout << "Yes"<< endl;
  }
  else{
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#define FOR(i, n) for (int i = 1; i <= n; i++)
#define REP(i, n) for (int i = 0; i < n; i++)

using namespace std;

#define N 110
char u[N], v[N], w[N];
int main() {
#ifdef QWERTIER
  freopen("in.txt", "r", stdin);
#endif
  int n;
  scanf("%d%s%s%s", &n, &u, &v, &w);
  int sum = 0;
  REP (i, n) {
    vector<char> x;
    x.push_back(u[i]);
    x.push_back(v[i]);
    x.push_back(w[i]);
    sort(x.begin(), x.end());
    if (x[0] == x[1] && x[1] == x[2])
      sum += 0;
    else if (x[0] == x[1] || x[1] == x[2])
      sum += 1;
    else
      sum += 2;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <deque>

using namespace std;

bool check_flg(vector<bool> &flag, vector<pair<vector<int>, vector<int> > > &na, int i) {
	for(int j = 0; j < na[i].second.size(); j++) {
		if(flag[na[i].second[j]] == false) return false;
	}
	return true;
}
int main() {
	int N, M;
	cin >> N >> M;

	vector<pair<vector<int>, vector<int> > > na(N);
	for(int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		na[a-1].first.push_back(b-1);
		na[b-1].second.push_back(a-1);
	}

	vector<int> n;
	//topological sort

	vector<bool> flag(N, false);
	deque<int> dp;
	for(int i = 0; i < N; i++) {
		if(na[i].second.size() == 0) {
			n.push_back(i);
			dp.push_back(i);
			flag[i] = true;
		}
	}

	while(dp.size() > 0) {
		int nn = dp.back();
		dp.pop_back();
		if(check_flg(flag, na, nn) == false) continue;
		if(flag[nn] == false) {
			n.push_back(nn);
			flag[nn] = true;
		}
		for(int i = 0; i < na[nn].first.size(); i++) {
			if(flag[na[nn].first[i]] == false)
				dp.push_back(na[nn].first[i]);
		}
	}

	//for(auto x: n) cout << x << " ";
	//cout << endl;

	vector<int> dd(N, 0);
	int out = 0;
	for(int i = 1; i < N; i++) {
		int nm = 0;
		for(int j = 0; j < na[n[i]].second.size(); j++) {
			nm = max(nm, dd[na[n[i]].second[j]] + 1);
	//		cout << na[n[i]].second[j] <<  "->" << n[i] << " " << nm << endl;
		}
		dd[n[i]] = nm;
		out = max(out, dd[n[i]]);
	}
	cout << out << endl;
	return 0;
}


Measured memory_bytes: 12156
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int a, b;
  cin >> a >> b;
  for(int x = 1; x <= 1250; x++) {
    if((8 * x) / 100 == a && (10 * x) / 100 == b) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
N,M = [int(i) for i in input().split()]
submissions = {str(i):[] for i in range(1,N+1)}
AC,WA = 0,0
for i in range(M):
    P,S = [j for j in input().split()]
    submissions[P].append(S)
for i in submissions:
    if 'AC' not in submissions[i]:
        continue
    for j in submissions[i]:
        if j == 'AC':
            AC+=1
            break
        WA +=1
print(AC,WA)

Measured memory_bytes: 31240
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,m;
	cin>>n>>m;
	bool ar[n+5];
	for(int i=1;i<=n;i++)
		ar[i]=false;
	int q;
	string s;
	int pen[n+5];
	for(int i=1;i<=n;i++)
		pen[i]=0;
	for(int i=0;i<m;i++)
	{
		cin>>q;
		cin>>s;
		if(s=="AC")
		{
			ar[q]=true;
		}
		if(s=="WA")
		{
			if(ar[q]==false)
				pen[q]++;
		}
	}
	int cor=0;
	for(int i=1;i<=n;i++)
		if(ar[i])
			cor++;
	int ans=0;
	for(int i=1;i<=n;i++)
		if(ar[i])
			ans+=pen[i];
	cout<<cor<<" "<<ans<<endl;
}


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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 1e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

int pref[N];
char c[200][200];

signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   int x, y, ans = INF;
   cin >> x >> y;
   if (x == y) {
      cout << 0;
      return 0;
   }
   if (-x == y) {
      cout << 1;
      return 0;
   }
   if (x < 0) {
      if (y < 0) {
         if (x <= y) {
            cout << abs(abs(x) - abs(y));
            return 0;
         }
         else {
            cout << abs(abs(x) - abs(y)) + 2;
            return 0;
         }
      }
      else {
         if (y == 0) {
            cout << abs(x);
            return 0;
         }
         cout << abs(abs(x) - abs(y)) + 1;
         return 0;
      }
   }
   else {
      if (y >= 0) {
         if (x <= y) {
            cout << y - x;
            return 0;
         }
         else {
            if (y == 0) {
               cout << abs(x - y) + 1;
               return 0;
            }
            cout << abs(x - y) + 2;
            return 0;
         }
      }
      else {
         cout << abs(x - abs(y)) + 1;
         return 0;
      }
   }

}

Measured memory_bytes: 256
//=========================
//  author:hliwen
//  date:2020.1.19
//=========================
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 200005
#define DEBUG puts("ok")
#define tie0 cin.tie(0),cout.tie(0)
#define fastio ios::sync_with_stdio(false)
#define File(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout)
using namespace std;
typedef long long ll;

template <typename T> inline void read(T &x) {
	T f = 1; x = 0; char c;
    for (c = getchar(); !isdigit(c); c = getchar()) if (c == '-') f = -1;
    for ( ; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x *= f;
}

int n, ans, x, lst;

int main() {
	lst = 1000000000;
	read(n); ans = 1;
	for (int i = 1; i <= n; ++i) {
		read(x);
		lst = min(lst, x);
		if (i == 1) continue;
		if (x <= lst) ans++;
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
h = [int(i) for i in input().split()]
def cost(i,j): return abs(h[i]-h[j])
INF = float("INF")
dp = [INF]*n
dp[0] = 0
for i in range(n):
    for j in range(i+1,min(i+k+1,n)):
        dp[j] = min(dp[j],dp[i]+cost(i,j))
print(dp[n-1])

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

int main(){
	int n;
	long long ans = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i){
		if((i%3) != 0 && (i%5) != 0)
			ans += i;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,len=0,p;
	cin>>a>>b;
	p=b;
	while(p>0)
	{
		len++;
		p/=10;
	}
	a=a*pow(10,len)+b;
	long long g=sqrt(a);
	if(g*g==a) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}

int main(int argc, char *argv[]){
    int n; string s; cin >> n >> s;
    int mx = 0, x = 0;
    rep(i, n){
        if(s[i] == 'I'){
            x++;
            mx = max(mx, x);
        }else{
            x--;
        }
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

#define ran 4444

int N, A, B;
char s[ran];
int q[ran], r;
int ans[ran];

int main() {
	scanf("%d%d", &A, &B);
	
	if(A<=B) {
		puts("Impossible");
		fflush(stdout);
		return 0;
	}
	
	N = A+B;
	r=0;
	for(int i=0;i<N;i++) {
		if(!r) {
			q[r++] = i;
			continue;
		}
		printf("? %d %d\n", i, q[r-1]);
		fflush(stdout);
		scanf("%s", s);
		if(*s=='N') r--;
		else q[r++] = i;
	}
	ans[q[0]] = 1;
	for(int i=0;i<N;i++)
		if(i!=q[0]) {
			printf("? %d %d\n", q[0], i);
			fflush(stdout);
			scanf("%s", s);
			ans[i] = (*s=='Y');
		}
	printf("! ");
	for(int i=0;i<N;i++) printf("%d", ans[i]);
	printf("\n");
	fflush(stdout);
	
	return 0;
}

Measured memory_bytes: 716
from collections import *
s = input()
p = 2019
c = Counter()
c[0] += 1
v = r = 0
k = 1
for i in s[::-1]:
    v += int(i)*k
    v %= p
    r += c[v]
    c[v] += 1
    k *= 10
    k %= p
print(r)

Measured memory_bytes: 9932
#B

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

c = "APPROVED"

for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 != 0 and a[i] % 5 != 0:
            c = "DENIED"
print(c)

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

using namespace std;

int main (void){
  string str;
  cin >> str;

  short alp[26] = {0};

  char* s = new char[str.size() + 1];

  strcpy(s, str.c_str());

  for (int i = 0; i < str.size() + 1; i++){
    alp[s[i] - 0x61]++;
  }


  // 全探索

  // 回数テーブル
  short n[26];

  short maxn = 0;
  short tmp = 0;
  short min = 1 << 14;
  short mintmp;
  bool en = false;
  for (char c = 'a'; c <= 'z'; c++){
    en = false;
    // いくつ空いているか？
    maxn = 0;
    tmp = 0;
    for (short i = 0; i < str.size(); i++){
      if(s[i] == c){
        if(maxn < tmp) maxn = tmp;
        tmp = 0;
        en = true;
      }else{
        tmp++;
        if(i == str.size() - 1){
          if(maxn < tmp) maxn = tmp;
        }
      }
    }

    if(en){
      //cout << c << " " << maxn << endl;
      n[c - 0x61] = maxn;
      mintmp = maxn;
      if(min > mintmp) min = mintmp;
    }
  }
  cout << min << endl;
    
  
  return 0;
}
  


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

int main() {
    int X, Y;
    cin >> X >> Y;

    if(X==Y)
    {
        cout << "-1" << endl;
    }
    else if(X % Y == 0 )
    {
        cout << "-1" << endl;
    }
    else if( Y==1)
    {
        cout << "-1" << endl;
    }
    else
    {
        cout << X << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    IOS;
    ll x,y;
    cin>>x>>y;
    if(y%2) cout<<"No";
    else
    {
        if(y>=2*x&&y<=4*x) cout<<"Yes";
        else cout<<"No";
    }
}


Measured memory_bytes: 3612
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
S = input()

S = list(S)

S[K-1] = S[K-1].lower()

print("".join(S))

Measured memory_bytes: 4336
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
    using ull = unsigned long long;
    ull n, m;
    cin >> n >> m;
    vector<ull> a(n, 0);
    for (ull i = 0; i < n; ++i)
        cin >> a[i];
    vector<pair<ull, ull>> bc(m);
    for (ull i = 0; i < m; ++i) {
        cin >> bc[i].first;
        cin >> bc[i].second;
    }
    sort(a.begin(), a.end());
    sort(bc.begin(), bc.end(), [](const auto& l, const auto& r) { return l.second > r.second; });
    ull i = 0;
    for (const auto& e : bc) {
        bool f = false;
        for (ull j = 0; j < e.first; ++j) {
            if (e.second < a[i]) {
                f = true;
                break;
            }
            a[i++] = e.second;
        }
        if (f)
            break;
    }
    ull sum = 0;
    for (auto e : a)
        sum += e;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,a,b,j,l,i;
    cin>>k>>a>>b;
    j=0;
    for(i=1;i>0;i++)
    {
        l=k*i;
        if(l>=a&&l<=b)
        {
            j=1;
        }
        if(l>b)
            break;
    }
    if(j==1)
        cout<<"OK";
    else
        cout<<"NG";

}


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

int main(void){
 
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    
    if(max({abs(a-b),abs(a-c),abs(a-d),abs(a-e),abs(b-c),abs(b-d),abs(b-e),abs(c-d),abs(c-d),abs(d-e)}) <= k){
        cout << "Yay!" <<endl;
    }
    else{
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 3552
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;
 
void call(int n) {
    for (int i=1; i<=n; ++i) {
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
        } else {
            while (x) {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
}
 
int main() {
    int n;
    cin >> n;
    call(n);
    return 0;
}

Measured memory_bytes: 1160
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
// #define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }
  void solve()
  {
  	int ans=0;
  	int n;
  	cin>>n;
  	for1(i,n)
  	{
  		for1(j,n)
  		{
  			if(i*j>n)break;
  			if(n-(i*j))ans++;
  		}
  	}
cout<<ans;


  }
  
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
    #endif
int t=1;
while(t--)
{
  solve();
}

    return 0;
  }


Measured memory_bytes: 3648
#include <stdio.h>

int main(void){

  int k,x;
  scanf("%d %d", &k, &x);
	int min = x-k+1;
	int max = x+k-1;
	for (int i = min; i < max; i++) {
		printf("%d ", i);
	}
	printf("%d\n", max);

  return 0;
}

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

int main(){
    int n,m; cin >> n >> m;
    vector<int> s(m),c(m);
    bool one = false;
    rep(i,m){
        cin >> s[i] >> c[i];
    } 


    for(int i= (n==1?0:(int)pow(10,n-1));i<(int)pow(10,n);++i){
        bool flag = false;
        for(int j=0;j<m;++j){
            if((i/(int)pow(10,n-s[j]))%10!=c[j]){
                flag = true;
                break;
            }
        }
        if(!flag){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
//

fun main() {
    agc003b()
}

fun agc003b() {
    val n = readLine()!!.toInt()
    var count = 0L
    var next = 0L
    for (i in 1..n) {
        val m = readLine()!!.toLong()
        if (m == 0L) {
            next = 0L
        } else {
            count += (next + m) / 2
            next = (next + m) % 2
        }
    }
    println(count)
}


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

typedef long long ll;
 
const ll MFac = 998244353;

const int COMMAX=200001;

vector<ll> fac(COMMAX); 
vector<ll> inv(COMMAX);
vector<ll> ifac(COMMAX); 

ll mpow(ll x, ll n){ 
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MFac;
        x = x*x % MFac;
        n = n >> 1;
    }
    return ans;
}

void InitializeCombination(void){
    fac[0] = ifac[0] = 1ll;
    inv[0] = 0ll;
    inv[1] = 1ll;
    fac[1] = ifac[1] = 1ll;
    for (int i = 2; i < COMMAX; i++){
        fac[i] = (fac[i-1] * (long long)i % (long long)MFac);
        inv[i] = ((long long)MFac - inv[MFac%i] * (long long)(MFac/i) % (long long)MFac);
        ifac[i] = (ifac[i-1] * inv[i] % (long long)MFac);
    }
}

long long comb(int n, int r){
    if (n < r) return 0LL;
    if (n < 0 || r < 0) return 0LL;
    return fac[n] * (ifac[r] * ifac[n-r] % MFac) % MFac;
}

int main(){
    // # count N-K, N-K+1, ..., N-1 separation of colors: sum( (N-1)C(N-1-K+i)*M*pow(M-1, N-1-K+i) ) in i=0 to K

    ll N, M, K;
    cin >> N >> M >> K;
 
    ll ans=0;

    InitializeCombination();

    for(ll i=0; i<=K; i++){
        ll tmp = comb(N-1, N-1-K+i)%MFac;
        //cout << "tmp=(N-1)C(N-1-K+i) " << tmp << endl;
        ll tmp2 = mpow( M-1, N-1-K+i )%MFac;
        tmp2 = M*tmp2%MFac;
        ans += tmp*tmp2;
        //cout << "i N-1-K+i tmp tmp2 ans " << i << " " << N-1-K+i << " " << tmp << " " << tmp2 << " " << ans << endl; 
        ans = ans%MFac;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7868
#include<stdio.h>
#include<math.h>

int main(){
    int a;
    scanf("%d",&a);
    int b = 0;
    for(int i = 0;i < 3;i++){
        int c = pow(10,i);
        if(a % 10 == 1) b += 9 * c;
        else if(a % 10 == 9)  b += c;
        a /= 10;
    }
    printf("%d\n",b);
}

Measured memory_bytes: 384