akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
#define show2(x,y) cout<<#x" = "<<x<<" "<<#y<<" = "<<y<<endl;
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> iipair;
typedef pair<unsigned,unsigned> uupair;
typedef vector<int> vec;
typedef vector<unsigned> uvec;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b && a!=c) || (a==c && a!=b) || (b==c && b!=a))  cout<<"Yes";
    else    cout<<"No";
}


Measured memory_bytes: 256
import numpy as np
import sys
input = sys.stdin.readline
n, m, q = map(int, input().split())
cnt = [[0]*(n+1)for _ in range(n+1)]
for _ in range(m):
    L, R = map(int, input().split())
    cnt[L][R] += 1

S = np.cumsum(cnt, axis=0).cumsum(axis=1)
L, R = map(np.array, zip(*[map(int, input().split()) for _ in range(q)]))

ans = S[R, R]-S[R, L-1]-S[L-1, R]+S[L-1, L-1]
print(*ans, sep='\n')

Measured memory_bytes: 66296
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {

        int y, m, d;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String line = br.readLine();

            String[] tbcConnection = line.split("/");
            int cnt = 0;
            int ok_cnt = 0;
            int end_flg = 0;
            for (String tbc : tbcConnection) {
                if (end_flg == 0){
                    if (Integer.parseInt(tbc) < 2019 && cnt == 0) {
                        ok_cnt++;
                    }

                    cnt++;



                    if(Integer.parseInt(tbc) > 2019 && cnt == 1 && ok_cnt == 0) {
                        System.out.println("TBD");
                        end_flg++;
                    } else if (Integer.parseInt(tbc) > 4 && cnt == 2 && ok_cnt == 0) {
                        System.out.println("TBD");
                        end_flg++;
                    } else if (Integer.parseInt(tbc) > 30 && cnt == 3 && ok_cnt == 0) {
                        System.out.println("TBD");
                        end_flg++;
                    }
                }

            }

            if (end_flg == 0) {
                System.out.println("Heisei");
            } else {
                System.out.println();
            }


        } catch (IOException e) {
            System.out.println(e);
        }
    }
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}

int main()
{
	int n;
	cin>>n;
	vector<int> d(n);
	rep(i,n)cin>>d[i];
	int ans=0;
	rep(i,n)repi(j,i+1,n)ans+=d[i]*d[j];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    N, M, X, Y = tuple(int(x) for x in input().split(" "))
    Xs = list(int(x) for x in input().split(" "))
    Ys = list(int(x) for x in input().split(" "))
    Xs.sort()
    Ys.sort()
    if Xs[-1] < Ys[0]:
        for n in range(Xs[-1]+1, Ys[0]+1):
            if X < n <= Y:
                print("No War")
                return
    print("War")




if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    int n; cin >> n;
    int pay = (n+999) / 1000 * 1000;
    int charge = pay - n;
    cout << charge;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define all(a) a.begin(),a.end
#define pb push_back
#define abs(a,b) (a-b>0?a-b:b-a)
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;

int main(){
    int a,b;
    cin >> a >> b;
    cout << (a-1)*(b-1) << endl;
    return 0;
}






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

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

  int sum = 0;
  vector<int> a(n);
  rep(i,0,n-1) {
    cin >> a[i];
    sum += a[i];
  }

  int avg_floor = sum / n;
  int avg_ceil = (sum + n - 1) / n;

  int ans_f = 0, ans_c = 0;
  rep(i,0,n-1) {
    ans_f += (a[i] - avg_floor) * (a[i] - avg_floor);
    ans_c += (a[i] - avg_ceil)  * (a[i] - avg_ceil);
  }

  cout << min(ans_f, ans_c) << endl;
  return 0;
}


Measured memory_bytes: 3636
import numpy as np
import functools
import operator
import sys

X, N = list(map(int, input().split()))

if N == 0:
    print(X)
    sys.exit()

ps = list(map(int, input().split()))

L = [x for x in range(max(ps) + 3)]

for p in ps:
    L.remove(p)


# min2nd_absval = 100000000
min_absval = 100000000
val = 100000
for i, l in enumerate(L):
    absval = abs(l - X)

    if min_absval > absval:
        min_absval = absval
        val = l


print(val)


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

int main(void){
    int A, B;
    cin >> A >> B;
    if(A==1){
        if(B==2){
            cout << 3 << endl;
        }
        else{
            cout << 2 << endl;
        }
    }
    else if(A==2){
        if(B==1){
            cout << 3 << endl;
        }
        else{
            cout << 1 << endl;
        }
    }
    else if(A==3){
        if(B==1){
            cout << 2 << endl;
        }
        else{
            cout << 1 << endl;
        }
    }
}


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

int main() {
  int N, A;
  cin >> N >> A;
  int x = N / 500;
  int y = N - 500 * x;
  if (A < y){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
'use strict';
function main(input) {
  const array = input.split(' ').map(i => Number(i));
  const P = array[0];
  const Q = array[1];
  const R = array[2];
  console.log(Math.min(P + Q, Q + R, R + P));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(void) {
    int N;cin>>N;
    vector<int> A(N);
    for (int i = 0 ; i < N ; i++) cin>>A[i];
    sort(A.begin(), A.end());
    cout << A.at(N - 1) - A.at(0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}

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

using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  vector<int> p(M);
  vector<string> s(M);

  for(int i = 0; i < M; i++){
    cin >> p[i] >> s[i];
  }
  vector<int> count(N);
  int ac = 0;
  int wa = 0;
  for(int i = 0; i < M; i++){
    if(s[i] == "WA" && count[p[i]] >= 0) {count[p[i]] += 1;}
    else if(s[i] == "AC" && count[p[i]] >= 0){ wa += count[p[i]]; ac++; count[p[i]] = -100; }
  }

  cout << ac <<" " <<  wa;
 
 return 0;
}

Measured memory_bytes: 6528
import sys
sys.setrecursionlimit(1000000)

n = int(input())
tree = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b, c = map(int, input().split())
    tree[a].append((b, c))
    tree[b].append((a, c))

depth = [0] * (n + 1)
def dfs(v, p, d):
    depth[v] = d
    for to, cost in tree[v]:
        if to != p:
            dfs(to, v, d + cost)

q, k = map(int, input().split())
dfs(k, 0, 0)
xy = [tuple(map(int, input().split())) for i in range(q)]

for x, y in xy:
    print(depth[x] + depth[y])


Measured memory_bytes: 132564
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line = null;
        double[][] points = new double[21][2];
        int n = 0;
        while ((line = reader.readLine()) != null) {
            if (line.isEmpty()) {
                continue;
            }
            String[] values = line.split(",");
            points[n][0] = Double.parseDouble(values[0]);
            points[n][1] = Double.parseDouble(values[1]);
            n++;
        }
        points[n][0] = points[0][0];
        points[n][1] = points[0][1];
        double s = 0.0;
        for (int i = 0; i < n; i++) {
            s += 0.5 * (points[i][0] * points[i + 1][1] - points[i + 1][0]
                    * points[i][1]);
        }
        out.println(Math.abs(s));
    }
}

Measured memory_bytes: 9784
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<vector<int>> s(M);
    REP(i,M){
        int k;
        cin >> k;
        REP(j,k){
            int ss;
            cin >> ss;
            ss--;
            s[i].emplace_back(ss);
        }
    }
    vector<int> p(M);
    REP(i,M) cin >> p[i];
    int ans = 0;
    REP(bits,1<<N){
        vector<int> pp(M);
        set<int> st;
        REP(i,N) if(bits >> i & 1) st.insert(i);
        REP(i,M){
            REP(j,s[i].size()) if(st.find(s[i][j]) != st.end()) pp[i]++;
        }
        int cnt = 0;
        REP(i,M) if(pp[i] % 2 == p[i]) cnt++;
        if(cnt >= M) ans++;
    }
    cout << ans << endl;
}

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

input = sys.stdin.readline


def ST():
    return input().rstrip()


def I():
    return int(input())


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


def LI():
    return list(MI())


S = list(ST())
T = list(ST())
ls = len(S)
lt = len(T)

ans = 1001
for i in range(ls - lt + 1):
    cnt = 0
    for j, t in enumerate(T):
        if S[i + j] != t:
            cnt += 1
    ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 67620
unittest
{
	assert( [ "serval" ].parse.expand.solve == 3 );
	assert( [ "jackal" ].parse.expand.solve == 2 );
	assert( [ "zzz" ].parse.expand.solve == 0 );
	assert( [ "whbrjpjyhsrywlqjxdbrbaomnw" ].parse.expand.solve == 8 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	// 文字の数をカウント
	long[ dchar ] ns;
	foreach( c; s ) ns[ c ]++;
	
	// 存在する文字で順番に試行
	auto ans = long.max;
	foreach( k, n; ns )
	{
		auto r = 0L;
		auto t = s.dup;
		while( n < t.length )
		{
			// ルールに従って操作を実行（文字はできるだけkに置き換える）
			foreach( i, ref c; t[ 0 .. $ - 1 ] )
			{
				if( c == k ) continue;
				c = t[ i + 1 ];
				n += ( c == k );
			}
			n -= ( t[ $ - 1 ] == k );
			t.length--;
			r++;
		}
		ans = min( ans, r );
	}
	return ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int n;cin>>n;//個数
  	int t,a;cin>>t>>a;//0ｍの気温、Aに近いのがよい  	
  	int ans=0,h;
  	int sa=99999999;
  	for (int i=0;i<n;i++){
      	cin>>h;//標高
    	if(sa>abs(t*1000-h*6-a*1000)){
        	sa=abs(t*1000-h*6-a*1000);
          	ans=i+1;
        }
    }
  	cout<<ans<<endl;
}



Measured memory_bytes: 256
N = int(input())
nums = [int(x) for x in input().split()]
cnt = 0
loop = True
while loop:
    if not all([n % 2 is 0 for n in nums]):
        loop = False
        break

    for i, n in enumerate(nums):
        nums[i] = n//2
    cnt += 1
print(cnt)


Measured memory_bytes: 2940
#include<iostream>
#include<math.h>
#include<set>
#include<algorithm>
#include<vector>
#include<iomanip>
using namespace std;

static long parseans(long j, long l)
{
    string k = "";
    long cur = 0;
    for (__int128 i = (__int128) j; i <= l; ++i)
    {
        cur *= 10;
        cur += k[i] - '0';
    }
    return cur;
}

static long gcd(long a, long b)
{
    if (b == 0)
    {
        return a;
    } else
    {
        return gcd(b, a % b);
    }
}
__int128 n , a , b;
vector<__int128> h;
static bool pri(__int128 k)
{
    if (k == 1) return false;
    for (__int128 i = 2; i * i <= k; i++)
    {
        
        if (k % i == 0) return false;
    }
    return true;
}

 __int128 calc(__int128 mid)
{
    __int128 p = mid;
    for(__int128 i = 0;i < n; i++)
    {
__int128 l = h[i] - p * b ;
        if( l > 0)
        {
           __int128 x = (l + a - b - 1) / (a - b);
            mid  = mid -x;
        }
        
    }
    return mid;
}

int main()
{
    long long w , e , o;
      cin >> w >> e >> o;
    n = w;
    a = e;
    b = o;
       h.resize(n);
    __int128 sum = 0;
    for(__int128 i = 0;i < n; i++)
    {
        long long d ;
        cin >> d;
        h[i] = d;
    }
    sort(h.rbegin(), h.rend());
    __int128 l = 0;
    __int128 r = n * h[0] + 1;
    while (l < r - 1)
    {
        int mid = (l + r) / 2;
        if ( calc(mid) < 0LL )
        {
            l = mid;
        }
        else
        {
            r = mid;
        }
    }
    cout << (long long)r << "\n";
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main(){
	int stone[10][5];
	int h;
	while(scanf("%d",&h) && h!=0){
		int score=0;
		for(int i=0;i<h;i++){
			for(int j=0;j<5;j++){
				scanf("%d",&stone[i][j]);
			}
		}

		int a=1;
		while(a!=0){
			a=0;
			for(int i=0;i<h;i++){
				if((stone[i][0]==stone[i][1]) && (stone[i][1]==stone[i][2]) && (stone[i][2]==stone[i][3]) && (stone[i][3]==stone[i][4])){
					score += stone[i][0]*5;
					for(int j=i;j>0;j--){
						for(int k=0;k<5;k++){
							stone[j][k] = stone[j-1][k];
						}
					}
					for(int j=0;j<5;j++){
						stone[0][j] = 10+j;
					}
					a++;
				}else if((stone[i][0]==stone[i][1]) && (stone[i][1]==stone[i][2]) && (stone[i][2]==stone[i][3])){
					score += stone[i][0]*4;
					for(int j=i;j>0;j--){
						for(int k=0;k<4;k++){
							stone[j][k] = stone[j-1][k];
						}
					}
					for(int j=0;j<4;j++){
						stone[0][j] = 10+j;
					}
					a++;
				}else if((stone[i][1]==stone[i][2]) && (stone[i][2]==stone[i][3]) && (stone[i][3]==stone[i][4])){
					score += stone[i][1]*4;
					for(int j=i;j>0;j--){
						for(int k=1;k<5;k++){
							stone[j][k] = stone[j-1][k];
						}
					}
					for(int j=1;j<5;j++){
						stone[0][j] = 10+j;
					}
					a++;
				}else if((stone[i][0]==stone[i][1]) && (stone[i][1]==stone[i][2])){
					score += stone[i][0]*3;
					for(int j=i;j>0;j--){
						for(int k=0;k<3;k++){
							stone[j][k] = stone[j-1][k];
						}
					}
					for(int j=0;j<3;j++){
						stone[0][j] = 10+j;
					}
					a++;
				}else if((stone[i][1]==stone[i][2]) && (stone[i][2]==stone[i][3])){
					score += stone[i][1]*3;
					for(int j=i;j>0;j--){
						for(int k=1;k<4;k++){
							stone[j][k] = stone[j-1][k];
						}
					}
					for(int j=1;j<4;j++){
						stone[0][j] = 10+j;
					}
					a++;
				}else if((stone[i][2]==stone[i][3]) && (stone[i][3]==stone[i][4])){
					score += stone[i][2]*3;
					for(int j=i;j>0;j--){
						for(int k=2;k<5;k++){
							stone[j][k] = stone[j-1][k];
						}
					}
					for(int j=2;j<5;j++){
						stone[0][j] = 10+j;
					}
					a++;
				}
			}
		}
		cout<<score<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
int main() 
{
int n,a,b,c,d;
cin>>n;
a=n/1000;
b=n/100-10*a;
c=(n%100-d)/10;
d=n%10;
  if((a==b and b==c) or (b==c and c==d))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
return 0;
}


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

using namespace std;
using ll = long long;

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

	int res = 0;
	for (int i = a; i <= t; i += a) {
		res += b;
	}

	cout << res << endl;

	return 0;
}


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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		int M = nextInt();
		Pair[] p = new Pair[M];
		ArrayList<Pair> list = new ArrayList<>();
		for(int i =0;i<M;i++){

			p[i]=new Pair(nextInt(),nextInt(),i);
			list.add(p[i]);
		}
		Collections.sort(list,Pair.getComparator());

		int cnt=0;
		int bef=-1;
		for(Pair x:list){
			if(bef!=x.N){
				cnt=0;
				bef=x.N;
			}
			cnt++;
			x.cnt=cnt;
		}
		for(Pair x:p){
			System.out.printf("%06d%06d\n",x.N,x.cnt);
			System.out.flush();
		}
	}

	public static class Pair {
		int N;
		int V;
		int idx;
		int cnt;

		Pair(int N, int V,int idx) {
			this.N = N;
			this.V = V;
			this.idx=idx;
		}

		public int getN() {
			return N;
		}

		public int getV() {
			return V;
		}


		public int getIdx() {
			return idx;
		}

		public void setIdx(int idx) {
			this.idx = idx;
		}

		public static Comparator<Pair> getComparator() {
			return Comparator.comparing(Pair::getN).thenComparing(Pair::getV);
		}
		public static Comparator<Pair> getComparator2() {
			return Comparator.comparing(Pair::getIdx);
		}
	}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 78120
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << v.first << " " << v.second;
    return ostr;
}

int main() {
    int N; cin >> N;
    vector<int> L(N); rep(i, N) cin >> L[i];

    map<int,  int> m;
    rep(i, N) m[L[i]]++;

    for (auto v : m) {
        if (v.second > 1) {
            cout << "NO" << endl;
            exit(0);
        }
    }

    cout << "YES" << endl;
}


Measured memory_bytes: 10368
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1010;

int main()
{vector<int> v[N];
    int n,T;
    cin>>n>>T;
    while(T--)
    {
        int c;
        cin>>c;
        if(c==0)
        {
            int t,x;
            cin>>t>>x;
            v[t].push_back(x);
        }
        else if(c==1)
        {
            int t;
            cin>>t;
            int size=v[t].size();
            if(size)
            {
                cout<<v[t][0];
                for(int i=1;i<size;i++)
                {
                    cout<<" "<<v[t][i];
                }
            }
            cout<<endl;
        }
        else
        {
            int t;
            cin>>t;
            v[t].clear();
        }
    }
}


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

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

typedef long long int ll;

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


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

  map<int,int> mp;
  REP(i,N){
    int a;
    cin >> a;
    mp[a]++;
  }

  vector<int> list;

  for(auto &v: mp){
    list.push_back(v.second);
  }
  sort(ALL(list));
  reverse(ALL(list));

  int ans = 0;
  FOR(i,K,list.size()){
    ans += list[i];
  }


  cout << ans << endl;
}



Measured memory_bytes: 10748
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;
int x[100005];
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	rep(i,N){
		int a;
		cin >> a;
		x[a]++;
	}
	int ans = 1;
	for(int i=N-1;i>=0;i-=2){
		if(i!=0)ans *= 2;
		ans %= (int)mod;
		if(x[i]!=2&&i!=0){
			cout << 0 << endl;
			return 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int dp[1001][1001];
int main(void){
	int i,j,w,n,wei[1000],val[1000],max,nm,cnt=0;
	while(1){
		scanf("%d",&w);
		if(w==0)break;
		scanf("%d",&n);
		for(i=0;i<n;i++) scanf("%d,%d",&val[i],&wei[i]);
		for(i=0;i<=n;i++){
			for(j=0;j<=w;j++) dp[i][j]=-1;
		}
		dp[0][0]=0;
		for(i=0;i<n;i++){
			for(j=0;j<=w;j++){
				if(dp[i][j]!=-1){
					if(dp[i+1][j]<dp[i][j]) dp[i+1][j]=dp[i][j];
					if(j+wei[i]<=w){
						if(dp[i+1][j+wei[i]]<dp[i][j]+val[i]) dp[i+1][j+wei[i]]=dp[i][j]+val[i];
					}
				}
			}
		}
//		for(i=0;i<=n;i++){
//			for(j=0;j<=w;j++){
//				printf("%d ",dp[i][j]);
//			}
//			printf("\n ");
//		}
		max=-1;
		for(i=0;i<=w;i++){
			if(max<dp[n][i]){
				max=dp[n][i];
				nm=i;
			}
		}
		cnt++;
		printf("Case %d:\n",cnt);
		printf("%d\n",max);
		printf("%d\n",nm);
	}
	return 0;
}

Measured memory_bytes: 4516
import Control.Applicative
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Bool (bool)
import Data.Char (isSpace)

main :: IO ()
main = solve <$> f <*> f >>= print
  where
    f = readil B.readInt <$> B.getLine

solve :: [Int] -> [Int] -> Int
solve [n, _] = f . (n -) . sum
  where
    f x = if x >= 0 then x else (-1)

readil :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a]
readil f = unfoldr $ \s -> do
  (n, s') <- f s
  return (n, B.dropWhile isSpace s')


Measured memory_bytes: 4760
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

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

int main(){
    int x; cin >> x;
    for(int i = x; i <= 1000000; i++){
        if(isPrime(i)){
            cout << i << endl;
            return 0;
        }
    }
}
    



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

#define ff              first
#define ss              second
//#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mci             map<char,int>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--)
using namespace std;
//template <typename T> 
const double PI = acos(-1.0);
 
double deg2rad(double degree) {
    return degree * PI / 180.0;
}
  

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
//       #ifndef ONLINE_JUDGE
//     // for getting input from input.txt
//     freopen("input.txt", "r", stdin);
//     // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
// #endif 
//we can create an array o
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double deg1 = (H * 30)+(M*6)/12;
    double deg2 = M * 6.0;
    double diff = abs(deg1 - deg2);
    cout << fixed << setprecision(10) << sqrt(A * A + B * B - 2 * A * B * cos(deg2rad(diff))) << endl;

 cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;

return 0;
}

Measured memory_bytes: 4164
#include<bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int M[105][105];

signed main()
{
        int W,H,N; cin>>W>>H>>N;
        while(N--){
                int x,y,a; cin>>x>>y>>a;
                if(a==1) REP(i,H) for(int j=0;j<x;j++){
                        M[i][j]=1;
                }
                if(a==2) REP(i,H) for(int j=x;j<W;j++){
                        M[i][j]=1;
                }
                if(a==3) for(int i=0;i<y;i++) REP(j,W){
                        M[i][j]=1;
                }
                if(a==4) for(int i=y;i<H;i++) REP(j,W){
                        M[i][j]=1;
                }
        }
        int ans=0;
        REP(i,H) REP(j,W) if(M[i][j]==0) ans++;
        cout<<ans<<endl;
}


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

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

	for(int i = 0; i < 8; i++)mp[i] = 0;
	int count = 0;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		if(a >= 3200)count++;
		else mp[a / 400]++;
	}

	int cnt = 0;
	for(auto a : mp){
		if(a.second > 0)cnt++;
	}
	if(cnt == 0) cout << 1 << " " << count << endl;
	else cout << cnt << " " << cnt + count << endl;
}

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

int main()
{
	int n;
	cin >> n;
	string s; 
	cin >>s;
	int c=0;	//counter
	int r=1000000000;
    int b=0;
	for(int i=0;i<n;i++){
    	if(s[i]=='#'){
        	b++;
        }
    }	
    int white=n-b;
  int w=white;
    b=0;
    for(int i=0;i<n;i++){
    	if(s[i]=='#'){
          	b++;
        }else{
        	w--;
        }
        c=b+w;
        if(r>c){
        	r=c;
        }
        //cout <<c << " ";
    }	
	cout << min(r,white) << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String[] input = sc.nextLine().split(" ");

        // 回数カウンタ
        int count = 0;
        // 数字が2で割り切れなくなるまでループを繰り返す
        while(true){
            // 入力すべてが2で割り切れるかどうかを確かめる
            for(int i = 0;i < n;i++){
                int tmp = Integer.parseInt(input[i]);
                // 2で割り切れる時、数字を置き換える
                if(tmp % 2 == 0) {
                    input[i] = Integer.toString(tmp/2);
                // ２で割り切れない時、そこでループを終了する
                } else {
                    // ２で割り切れなくなったときだけ結果を出力
                    System.out.println(count);
                    return;
                }
            }
            
            // すべてループを回ったら2で割り切れているのでカウントアップ
            count++;
        }
    }
}


Measured memory_bytes: 22868
// 移動方法が200000通りしかないので素朴な深さ優先探索
#include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
int m,n;
bool a[92][92];
bool v[92][92]; // そこを通ったか
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

int dfs(int w, int h, int cnt) {
  v[h][w] = true;

  int res = cnt;
  for (int i = 0; i < 4; i++) {
    int nw = w + dx[i];
    int nh = h + dy[i];
    if (!v[nh][nw] && a[nh][nw]) {
      res = max(res, dfs(nw, nh, cnt + 1));
    }
  }

  v[h][w] = false;

  return res;
}

int main() {
  // ifstream cin("../test.txt");
  while (true) {
    cin >> m >> n;
    if (!(m|n)) break;
    int t;
    for (int i = 0; i < n+2; i++) {
      for (int j = 0; j < m+2; j++) {
        a[i][j] = false;
        v[i][j] = false;
      }
    }

    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        cin >> t;
        a[i][j] = t; // h、w
      }
    }

    int mx = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (a[i][j]) {
          mx = max(mx, dfs(j, i, 1));
        }
      }
    }

    cout << mx << endl;
  }
}

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define pb push_back


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 1000100010010010;
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }
//template<typename T> auto cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int n;
vi arr;

int dp[3010][3010];

int dfs(int l, int r){

    if(l > r) return 0;

    if(dp[l][r] > -inf) return dp[l][r];

    if(!(((r - l + 1) ^ n) & 1)){
        return dp[l][r] = max(arr[l] + dfs(l + 1, r), arr[r] + dfs(l, r - 1));
    }else{
        return dp[l][r] = min(dfs(l + 1, r) - arr[l], dfs(l, r - 1) - arr[r]);
    }
    
}


signed main(){


    cin.tie(0);
    ios::sync_with_stdio(false);

    n = input();
    rep(i,0,n) arr.pb(input());

    rep(i,0,3010) rep(j,0,3010) dp[i][j] = -inf;

    print(dfs(0, n - 1));


    




    






    



    


    

}



Measured memory_bytes: 71424
/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
using namespace std;
const int N = 105;
int n,k;
int d[N];
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	while(k--){
		int m,x; cin >> m;
		up(i,1,m){
			cin >> x;
			d[x]++;
		}
	}
	int ans = 0;
	up(i,1,n) ans += (d[i] == 0);
	cout << ans;
}

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

typedef pair<int,int> ii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define psf push_front
#define pof pop_front
#define mkp make_pair
#define mkt make_tuple
#define all(x) x.begin(), x.end()

int n;
const int MAXS = 5e5;
int fen[MAXS + 3];
int a[MAXS + 3];
queue<int> elems[MAXS + 3];
vii queries[MAXS + 3];

void update(int pos, int delta){
    while(pos <= n){
        fen[pos] += delta;
        pos += pos & (-pos);
    }
}

int query(int pos){
    int answer = 0;
    while(pos){
        answer += fen[pos];
        pos -= pos & (-pos);
    }
    return answer;
}

int main(){
	ios::sync_with_stdio(false), cin.tie(nullptr);
    cin>>n;
    int q; cin>>q;
    vii arq;
    set<int> ft;
    for (int i=1; i<=n; i++){
        cin>>a[i];
        elems[a[i]].push(i);
        auto ff = ft.find(a[i]);
        if (ff == ft.end()){
            update(i, 1);
            ft.insert(a[i]);
        }
    }
    for (int i=0; i<q; i++){
        int l,r; cin>>l>>r;
        queries[l].pb(ii(i, r));
    }
    
    vii ans;
    for (int i=1; i<=n; i++){
        //first answer all, then update:
        for (int j=0; j<queries[i].size(); ++j){
            int r = queries[i][j].second;
            int index = queries[i][j].first;
            int cans = query(r);
            ans.pb(ii(index, cans));
        }
        int el = a[i];
        int pos = elems[el].front();
        elems[el].pop();
        update(pos, -1);
        if (!elems[el].empty()) update(elems[el].front(), 1);
    }
    sort(all(ans));
    for (int i=0; i<q; i++){
        cout<<ans[i].second<<'\n';
    }
    
	return 0;
}
/*
NARCO
*/


Measured memory_bytes: 393400
/*Author- Soumak Poddar*/

#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define sll signed long long int
#define ull unsigned long long int
#define um unordered_map
#define us unordered_set
#define mm multimap
#define mp make_pair
#define pb push_back
#define M 1000000007

bool comp(pair<int,int> a,pair<int,int> b)
{
   return a.second<b.second;
}

template<typename T>
T gcd(T a,T b)
{
   if(a==0)
      return b;
   return gcd(b%a,a);
}
template<typename T>
T lcm(T a,T b)
{
   ll g=gcd<T>(a,b);
   return (a*b)/g;
}
template<typename T>
bool isprime(T n)
{
   if(n<=1)
      return false;
   for (int i = 2; i < n; i++)
      if (n % i == 0)
         return false;
   return true;
}

void solve();
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);

   #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("error.txt", "w", stderr);
      freopen("output.txt", "w", stdout);
   #endif
   
   int t=1;
   // cin>>t;
   while(t--)
   {
      solve();
      cout<<"\n";
   }
   cerr<<"Time Taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
   return 0;
}
void solve()
{
   int k;
   cin>>k;
   int a=0;
   int ans=-1;
   for(int i=1;i<=k;i++)
   {
      a=(a*10+7)%k;
      if(a==0)
      {
         ans=i;
         break;
      }
   }
   cout<<ans;
}

Measured memory_bytes: 3772
import java.util.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                long x = Math.abs(sc.nextLong());
                long k = sc.nextLong();
                long d = sc.nextLong();
                sc.close();
                if(x / d > k){
                        System.out.println(x - d * k);
                }else{
                        long yono = x / d;
                        k -= yono;
                        x = x % d;
                        if(k % 2 == 0){
                                System.out.println(x);
                        }else{
                                System.out.println(d - x);
                        }
                }
        }
}

Measured memory_bytes: 35692
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

H, W = ISI()
a = [["#"*(W+2)] for _ in range(H+2)]
for i in range(H):
    s = ["#" + IS() + "#"]
    a[i+1] = s
for i in range(H+2):
    print(*a[i])

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;


int main(){
  int n;
  int x[400],y[400],b[400],p[400];
  cin >> n;
  for(int i=0;i<n;++i) cin >> x[i] >> y[i] >> b[i] >> p[i];

  for(int i=0;i<n;++i){
    int cnt;
    if(b[i]>=5 && p[i]>=2)cnt = (x[i]*b[i] + y[i]*p[i])*0.8;
    else {
     int  a = x[i]*b[i] + y[i]*p[i];
     int c;
     if(b[i]<5) c = x[i]*5;
     else c = x[i]*b[i];
     if(p[i]<2) c += y[i]*2;
     else c += y[i]*p[i];

     c *= 0.8;

     if(a>c) cnt = c;
     else cnt =a;
    }
      cout << cnt << endl;
  }
  
  return 0;
}



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

int main(){
    int s;
    cin >> s;
    int ans1 = s/100;
    int ans2 = s%100;
    if(1 <= ans1 && ans1 <= 12){
        if(1<=ans2 && ans2<=12){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if(1 <= ans2 && ans2 <= 12){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }
    return 0;

}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] ar = new int[n];
		for(int i=0 ; i<n ; i++ )
		{
			ar[i] = sc.nextInt();
		}
		printAr(ar,-1);
		for(int j = 1; j < n ;j++)
		{
			int tar = ar[j];
			int k = j;
			while(k > 0 && tar < ar[k-1])
			{
				ar[k] = ar[k-1];
				k--;
				ar[k] = tar;
			}
			printAr(ar,j);
			
			
		}
	}
	public static void printAr(int[] a,int c){
		int i;
		for(i = 0 ; i < a.length-1 ; i++){
			System.out.print(a[i]+" ");
		}
			System.out.println(a[i]);	
	}
	
}
 

 

Measured memory_bytes: 33168
#include<bits/stdc++.h>
using namespace std;
const int mod= 1000000007;

void add_self(int &a, int b){
      a+=b;
      while(a>mod)
            a-=mod;
}

int main(){
      string s;
      int d;
      cin>>s>>d;
      int len=s.length();
      vector<vector<int>>dp(d, vector<int>(2, 0));

      dp[0][0] = 1;

      for(int where = 0; where < len; where++){
            
            vector<vector<int>>new_dp(d, vector<int>(2, 0));
            
            for(int sum = 0; sum < d; sum++){
                  
                  for(bool sm_already: {false, true}){
                        
                        for(int digit = 0; digit < 10; digit++){
                              
                              if((digit > s[where] - '0') && !sm_already){
                                    break;
                              }
                              //add_self(new_dp[(sum + digit)%d][sm_already || (digit < (s[where] - '0'))], dp[sum][sm_already]);
                              new_dp[(sum + digit)%d][sm_already || (digit < (s[where] - '0'))] = (new_dp[(sum + digit)%d][sm_already || (digit < (s[where] - '0'))] + dp[sum][sm_already])%mod;
                        }
                  }
            }
            dp = new_dp;
      }
      int ans=dp[0][1]+dp[0][0];
      ans--;
      ans%=mod;
      if(ans<0)ans=mod-1;
      cout<<ans;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N;
    cin >> N;

    int A;
    
    rep(i,N) {
        cin >> A;
        if (A % 2 == 0) {
            if (A % 3 != 0 && A % 5 != 0) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;

int max(int a, int b) { return a < b ? b : a; }
int board[2010][2010];
int main() {
    int N, K; scanf("%d%d", &N, &K);

    int sum = 0, white = 0;
    for(int i=0; i<N; i++) {
        int x, y; char c; scanf(" %d%d %c", &x, &y, &c);
        x %= 2*K, y %= 2*K;
        if(c == 'B') board[x+1][y+1]++, sum++;
        if(c == 'W') board[x+1][y+1]--, sum--, white++;
    }

    for(int i=1; i<=2*K; i++) {
        for(int j=1; j<=2*K; j++) {
            board[i][j] += board[i][j-1];
        }
    }

    for(int j=1; j<=2*K; j++) {
        for(int i=1; i<=2*K; i++) {
            board[i][j] += board[i-1][j];
        }
    }

    int ma = -(1 << 25);
    for(int i=0; i<=K; i++) {
        for(int j=0; j<=K; j++) {
            // pattern 1
            int a = board[i][j];
            int b = board[i+K][j+K] - board[i+K][j] - board[i][j+K] + board[i][j];
            int c = board[2*K][j] - board[i+K][j];
            int d = board[i][2*K] - board[i][j+K];
            int e = board[2*K][2*K] - board[2*K][j+K] - board[i+K][2*K] + board[i+K][j+K];
            int tmp = a + b + c + d + e;
            ma = max(ma, max(tmp, sum - tmp));
        }
    }
    ma += white;
    printf("%d\n", ma);
    return 0;
}

Measured memory_bytes: 15872
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if(s=="SUN")
        cout << 7;
    else if(s=="MON")
        cout << 6;
    else if(s=="TUE")
        cout << 5;
    else if(s=="WED")
        cout << 4;
    else if(s=="THU")
        cout << 3;
    else if(s=="FRI")
        cout << 2;
    else if(s=="SAT")
        cout << 1;
    }



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

using namespace std;
using ll = long long int;

bool is_prime(ll n){
    ll k = pow(n, 0.5) + 1;
    if (n % 2 == 0 && n != 2){
        return false;
    }
    for (int i = 3; i < k; i+=2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}

int main() {
    ll X;
    cin >> X;
    while(!is_prime(X)){
        X += 1;
    }
    cout << X << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;
const int N=2e5+10;
struct node{
	ll l,r;
	bool operator < (const node &x)const{
		if(l!=x.l)return l<x.l;
		return r<x.r;
	}
	node(ll a=0,ll b=0){l=a,r=b;}
};
map<ll,vector<node> >s;
ll n,x,d;
ll sum[N];
int main()
{
	//freopen("H:\\c++1\\in.txt","r",stdin);
	//freopen("H:\\c++1\\out.txt","w",stdout);
	for(int i=1;i<N;i++)sum[i]=sum[i-1]+i;
	scanf("%lld%lld%lld",&n,&x,&d);
	if(x==0&&d==0){
		puts("1");return 0;
	}
	if(x!=0&&d==0){
		printf("%lld\n",n+1);return 0;
	}
	if(d<0)d*=-1,x*=-1;
	ll L=0,R=0;
	for(ll i=0;i<=n;i++){
		ll t=i*x;
		L=sum[i-1];
		R=sum[n-1]-sum[max(0ll,n-i-1)];
		L+=t/d,R+=t/d;
		t%=d;
		if(t<0)t+=d,L--,R--;
		s[t].push_back(node(L,R));
	}
	ll ans=0;
	for(auto it:s){
		sort(it.se.begin(),it.se.end());
		L=it.se[0].l,R=it.se[0].r;
		for(node v:it.se){
			if(v.l>R){
				ans+=R-L+1;
				L=v.l,R=v.r;
			}
			else{
				R=max(v.r,R);
			}	
		}
		ans+=R-L+1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 23680
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class agc029_a {
public:
    void solve(istream& in, ostream& out) {
        string S;
        in >> S;
        int n = S.size();
        long long res = 0;
        int cnt = 0;
        for (int i = n - 1; i >= 0; --i) {
            if (S[i] == 'W') {
                ++cnt;
            } else {
                res += cnt;
            }
        }
        out << res << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	agc029_a solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    string str;
    cin >> str;
    int ans=0;
    vector<int> vec;
    char cur_s=str[0];
    int cnt=1;
    for(int n=1; n<N; n++) {
        if(cur_s==str[n]) {
            cnt++;
        } else {
            vec.push_back(cnt);
            cnt = 1;
            cur_s = str[n];
        }
    }
    vec.push_back(cnt);
    vector<int> s_vec(vec.size()+1, 0);
    for(int i=0; i<vec.size(); i++) {
        s_vec[i+1] = vec[i]+s_vec[i];
    }

    for(int i=0; i<vec.size(); i++) {
        if(str[0]=='1') {
            if(i%2) {
                ans = max(ans, s_vec[(int)min(i+K*2, (int)s_vec.size()-1)]-s_vec[i]);
            } else {
                ans = max(ans, s_vec[(int)min(i+K*2+1, (int)s_vec.size()-1)]-s_vec[i]);
            }
        } else {
            if(i%2==0) {
                ans = max(ans, s_vec[(int)min(i+K*2, (int)s_vec.size()-1)]-s_vec[i]);
            } else {
                ans = max(ans, s_vec[(int)min(i+K*2+1, (int)s_vec.size()-1)]-s_vec[i]);
            }
        }
    }
    cout << ans << endl;
    

    return 0;
    
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i > 0; i--)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
template <typename Iter> std::string join(Iter begin, Iter end, std::string const& separator){ std::ostringstream result; if (begin != end){ result << *begin++; }; while (begin != end){ result << separator << *begin++; }; return result.str(); }
using namespace std;
typedef long long ll;
void solve() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) {
    cin >> a[i];
  }
  ll first = *max_element(ALL(a));
  if(count(ALL(a), first) > 1) {
    REP(i, n) {
      cout << first << endl;
    }
  } else {
    ll second = min(a[0], a[1]);
    for(auto x: a) {
      if(x == first) continue;
      if(x > second) second = x;
    }
    for(auto x: a) {
      if(x == first) {
        cout << second << endl;
      } else {
        cout << first << endl;
      }
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 3200