akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
typedef long long ll;
using namespace std;

int main(){
  ll L,R;
  cin >> L >> R;
  ll mini = 200000;
  for(ll i=L;i<=min(R,L+2018);i++){
    for(ll j=i+1;j<=min(R,L+2018);j++){
      mini = min(mini,((i*j)%2019));
    }
  }
  cout << mini << endl;
  return 0;
}


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

int main(){
  int m, n, s, i;
  char no[100];
  while(cin >> m >> n, m != 0 || n != 0) {
    queue<int> q;
    for(int j = 0; j < m; j++) q.push(j+1);
    i = 1;
    while(n--) {
      if(q.size() != 1) {
	cin >> no;
	int p = q.front(); q.pop();
	if(i%3 == 0 && i% 5 == 0) {
	  if(strcmp(no, "FizzBuzz") == 0) q.push(p);
	}
	else if(i % 3 == 0 && strcmp(no,"Fizz") == 0) q.push(p);
	else if(i % 5 == 0 && strcmp(no ,"Buzz") == 0)  q.push(p);
	else if(i % 3 != 0 && i % 5 != 0 && i == atoi(no)) q.push(p);
	i++;
      }
      else cin >> no;
    }
    
    vector<int> v(1050);
    while(q.size()) {
      v.push_back(q.front());
      q.pop();
    }
    sort(v.begin(), v.end());
    while(v.size()) {
      if(v[0]) {
	cout << v[0];
	if(v.size() - 1) cout << ' ';
      }
      v.erase(v.begin());
    }
    cout << endl;
  }
  return 0;
}

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

N=int(input())
c = 0
for _ in range(N):
    d1,d2 =map(int,input().split())
    if d1 == d2:
        c += 1
        if c == 3:
            print('Yes')
            exit()
    else:
        c = 0

print('No')


Measured memory_bytes: 61804
/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

#include <bits/stdc++.h>
#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll long long
#define ld  double

#define HabdModeActive ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first
#define PI acos(-1)
#define MAX 5000005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);


int main() {
    HabdModeActive
    int n,m;
    cin>>n>>m;
    ll arr[n];
    for(int i=0 ; i<n; i++)
        cin>>arr[i];
    vector<pair<ll,ll>>vec;
    for(int i=0 ; i<m; i++)
    {
        ll b,c;
        cin>>b>>c;
        vec.push_back({c,b});
    }
    sort(arr,arr+ n);
    sort(vec.rbegin(),vec.rend());
    int in = 0;
    ll sum = 0;
    for(int i=0 ; i<n; i++)
    {
        while(in < m && vec[in].second == 0)
            in++;
        if(in < m && arr[i] < vec[in].first )
        {
            vec[in].second--;
            sum+= vec[in].first;
        }
        else{
            sum += arr[i];
        }
    }
    cout<<sum;

    return 0;
}
/*
 * int n, e;
    cin >> n >> e;
    int arr[n];
    for (int i = 0; i < n; i++)
        cin >> arr[i];

    ll mx = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i; j >= 0; j--) {
            for (int k = n - 1; k > i; k--) {
                for (int r = k; k < n; k++) {
                    priority_queue<ll> q;
                    ll sum = 0;
                    ll op = e;
                    for (int g = 0; g <= i && op > 0; g++, op--)
                        sum += arr[g], q.push(-arr[g]);
                    for (int g = 0; g <= j && op > 0; g++, op--) {
                        if (q.top() < 0) {
                            e--;
                            sum += q.top();
                            q.pop();
                        }
                    }

                    for (int g = n - 1; g >= k && op > 0; g--, op--)
                        sum += arr[g], q.push(-arr[g]);
                    for (int g = n-1; g >= r && op > 0; g--, op--) {
                        if (q.top() < 0) {
                            e--;
                            sum += q.top();
                            q.pop();
                        }
                    }
                    mx = max(sum, mx);
                }
            }
        }
    }
 */

Measured memory_bytes: 6088
n,k,c = map(int,input().split())
s = list(input())

L = []
R = []

i = -1
j = n  

for ki in range(k):
  while i < n:
    i += 1
    if s[i] == 'o':           
      L += [i]
      i += c
      break

for ki in range(k):      
  while 0 <= j:
    j -= 1
    if s[j] == 'o':          
      R += [j]
      j -= c
      break
      
for i in range(k):
  if L[i] == R[-i-1] :
    print(L[i]+1)

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

typedef long long ll;

#define N 100010
#define INF 1e9

int n;
int A[N];
int Ans1[N],Ans2[N];


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


int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		A[i]=read();
	}
	Ans1[1]=1;
	for(int i=2;i<=n;i++)
	{
		Ans1[i]=Ans1[i-1]+20000;
	}
	for(int i=1;i<=n;i++)
	{
		Ans2[A[i]]=INF-(n-i)-Ans1[A[i]];
	}
	for(int i=1;i<=n;i++)
		printf("%d ",Ans1[i]);
	cout<<endl;
	for(int i=1;i<=n;i++)
		printf("%d ",Ans2[i]);
	cout<<endl;
	return 0;
}

Measured memory_bytes: 896
import java.util.ArrayDeque;
import java.util.Collections;
import java.util.Deque;
import java.util.Scanner;
import java.util.Queue;
import java.util.PriorityQueue;

public class Main {

    static int N;
    static long[] a;
    static long answer;
    static long leftSum[];
    static long rightSum[];

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        N = sc.nextInt();

        a = new long[3 * N];
        leftSum = new long[N + 1];
        rightSum = new long[N + 1];
        Queue<Long> left = new PriorityQueue<Long>();
        Queue<Long> right = new PriorityQueue<Long>(Collections.reverseOrder());


        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextLong();
            if (i < N) {
                left.add(a[i]);
            }
            else if (2 * N <= i){
                right.add(a[i]);
            }
        }

        sc.close();

        leftSum[0] = sum(left);
        for (int i = N; i < 2 * N; i++) {
            left.add(a[i]);
            leftSum[i - (N - 1)] = leftSum[i - N] + a[i] - left.poll();
        }

        rightSum[0] = sum(right);
        for (int i = 2 * N - 1; i >= N; i--) {
            right.add(a[i]);
            rightSum[2 * N - 1 - (i - 1)] = rightSum[2 * N - 1 - i] + a[i] - right.poll();
        }

        answer = -Long.MAX_VALUE;
        for (int i = 0; i < N  + 1; i++) {
            answer = Math.max(answer, leftSum[i] - rightSum[N - i]);
        }

        System.out.println(answer);
    }

    private static long sum(Queue<Long> queue) {
        return queue.stream().mapToLong(x -> (long)x).sum();
    }
}





Measured memory_bytes: 113924
from sys import stdin, setrecursionlimit
input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

X = int(input())
#S = input()
#N, M = map(int, input().split())
#A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
#ABC = [list(map(int, input().split())) for _ in range(N)]

print(lcm(X, 360) // X)


Measured memory_bytes: 65520
import sys
 
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
 
A_dash = []
for i in range(N):
    A_dash.append(A[i] - (i + 1))
 
A_dash.sort()
ans = -float("inf")
if N % 2 == 1:
    tmp = 0
    b = A_dash[N // 2]
    for i in range(N):
        tmp += abs(A_dash[i] - b)
    print(tmp)
else:
    tmp1 = 0
    b = A_dash[N // 2 - 1]
    for i in range(N):
        tmp1 += abs(A_dash[i] - b)
    
    tmp2 = 0
    b = A_dash[N // 2]
    for i in range(N):
        tmp2 += abs(A_dash[i] - b)
    print(min(tmp1, tmp2))

Measured memory_bytes: 30992
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

using E = tuple<int, int>;

vector<vector<E>> edge;
vector<bool> isVisited;

int dfs(int node, int bridge)
{
    int result = 1;
    isVisited[node] = true;

    for (auto e : edge[node]) {
        int v, j;
        tie(v, j) = e;
        if (!isVisited[v] && bridge != j) {
            result += dfs(v, bridge);
        }
    }

    return result;
}

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

    edge.resize(n);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        edge[a].push_back(E(b, i));
        edge[b].push_back(E(a, i));
    }

    int result = 0;
    isVisited.resize(n);
    rep(i, m)
    {
        fill(isVisited.begin(), isVisited.end(), false);
        if (dfs(0, i) != n) {
            result++;
        }
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main() {
 
double x1,x2,y1,y2;
double x,y,z;
scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
 
x = (x2-x1) * (x2-x1);
y = (y2-y1) * (y2-y1);
 
printf("%.11lf",sqrt(x+y));
 
 
return 0;
 
}


Measured memory_bytes: 2052
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

//Manhattan Wiring
public class Main{

	int h, w, ai, aj, bi, bj, res, INF = 1<<28, need, c;
	int[] dir;
	int[][] m, dist;
	int[][] d = {{-1,0},{0,1},{1,0},{0,-1}};
	
	boolean ok(int i, int j){
		return 0<=i&&i<h&&0<=j&&j<w;
	}
	
	boolean cancel(int n, int i, int j){
		if(n<3)return false;
		if(dir[n-1]==dir[n-2])return false;
		int K = dir[n-2], N = 0, M = 0;
		int k = n-2;
		while(0<=k && dir[k]==K){
			N++; k--;
		}
		while(0<=k && dir[k]==(dir[n-1]+2)%4){
			M++; k--;
		}
		if(k<0 || N < 2 || M==0)return false;
		for(int x=0;x<M;x++){
			int ni = i+x*d[dir[n-1]][0], nj = j+x*d[dir[n-1]][1];
			for(int y=0;y<N-1;y++){
				ni+=d[(K+2)%4][0]; nj+=d[(K+2)%4][1];
				if(m[ni][nj]!=0)return false;
			}
		}
		return true;
	}
	
	int bfs(){
		for(int[]a:dist)Arrays.fill(a, INF);
		dist[bi][bj] = 0;
		Queue<int[]> q = new LinkedList<int[]>();
		q.add(new int[]{bi, bj});
		while(!q.isEmpty()){
			int[] V = q.poll();
			int pi = V[0], pj = V[1];
			if((bi!=pi || bj!=pj) && m[pi][pj]==3)return dist[pi][pj];
			for(int k=0;k<4;k++){
				int ni = pi+d[k][0], nj = pj+d[k][1];
				if(ok(ni, nj)&&(m[ni][nj]==0 || m[ni][nj]==3)&&dist[ni][nj]==INF){
					dist[ni][nj] = dist[pi][pj]+1;
					q.add(new int[]{ni, nj});
				}
			}
		}
		return INF;
	}
	
	void dfs(int i, int j, int rest, int step){
		if(res<=step+need)return;
		if(rest < need)return;
		if(m[i][j]==2 && (i!=ai || j!=aj)){
			res = Math.min(res, step+bfs()); return;
		}
		if(cancel(step, i, j))return;
		int c = 0;
		for(int k=0;k<4;k++){
			int ni = i+d[k][0], nj = j+d[k][1];
			if(ok(ni, nj)&&m[ni][nj]==-1)c++;
		}
		if(2<=c)return;
		int x = m[i][j];
		m[i][j] = -1;
		for(int k=0;k<4;k++){
			int ni = i+d[k][0], nj = j+d[k][1];
			if(ok(ni, nj)&&(m[ni][nj]==0 || m[ni][nj]==2)){
				dir[step] = k;
				dfs(ni, nj, m[ni][nj]==0?(rest-1):rest, step+1);
			}
		}
		m[i][j] = x;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			h = sc.nextInt(); w = sc.nextInt();
			if((h|w)==0)break;
			m = new int[h][w];
			dist = new int[h][w];
			dir = new int[100];
			for(int i=0;i<h;i++)for(int j=0;j<w;j++){
				m[i][j] = sc.nextInt();
				if(m[i][j]==0)c++;
				if(m[i][j]==2){
					ai = i; aj = j;
				}
				if(m[i][j]==3){
					bi = i; bj = j;
				}
			}
			res = INF;
			need = bfs();
			if(need!=INF){
				need--;
				m[ai][aj] = -1;
				dfs(ai, aj, c, 0);
			}
			System.out.println(res==INF?0:res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
X, Y = $stdin.gets.split.map {|i| i.to_i }
if Y % 2 == 1
  puts 'No'
  exit
end
t = 2 * X - Y / 2
k = Y / 2 - X
if t < 0 || k < 0
  puts 'No'
  exit
end
# $stderr.puts "t = #{t}, k = #{k}"
puts 'Yes'


Measured memory_bytes: 14296
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	counter := map[int]int{}
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		counter[a]++
	}

	var ans int
	for _, v := range counter {
		ans += v & 1
	}
	fmt.Println(ans)
}

Measured memory_bytes: 8064
n = int(input())
a = list(map(int, input().split()))

a = sorted(a)
now_size = 0
ans = 1
for i in range(n):
    if 2*now_size < a[i]:
        ans = 1
    else:
        ans += 1
    now_size += a[i]
print(ans)

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

int main(){
  int n, a, b;
  a = b = 0;
  cin >>n;
  for(int i = 0;i<n;++i){
    int c;
    cin>>c;
    a += c;
    b=max(b, c);
  }
  cout<<a-b/2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

bool debug = false;
const int NIL = -1;
const int INF = 1000000000;
const int NUM = 100010;
clock_t START, END;

int V, E, r;

struct HeapNode {
	int d, u;
	bool operator < (const HeapNode& rhs) const {
		return d > rhs.d;
	}
};

struct Edge {
	int from, to, dist;
	Edge(int u, int v, int d) :from(u), to(v), dist(d) {}
};

struct Dijkstra {
	int n, m;
	vector<Edge> edges;
	vector<int> G[NUM];
	bool done[NUM];
	int d[NUM];
	int p[NUM];

	bool inq[NUM];
	int cnt[NUM];

	void init(int n) {
		this->n = n;
		for (int i = 0; i < n; i++)
			G[i].clear();
		edges.clear();
	}

	void AddEdge(int from, int to, int dist) {
		edges.push_back(Edge(from, to, dist));
		m = edges.size();
		G[from].push_back(m - 1);
	}

	void dijkstra(int s) {
		priority_queue<HeapNode> Q;
		for (int i = 0; i < V; i++)
			d[i] = INF;
		d[s] = 0;
		memset(done, 0, sizeof(done));
		Q.push({ 0, s });
		while (!Q.empty()) {
			HeapNode x = Q.top();
			Q.pop();
			int u = x.u;
			if (done[u])
				continue;
			done[u] = true;
			for (int i = 0; i < G[u].size(); i++) {
				Edge& e = edges[G[u][i]];
				if (d[e.to] > d[u] + e.dist) {
					d[e.to] = d[u] + e.dist;
					p[e.to] = G[u][i];
					Q.push({ d[e.to],e.to });
				}
			}
		}
	}

	bool bellman_ford(int s) {
		queue<int> Q;
		memset(inq, 0, sizeof(inq));
		memset(cnt, 0, sizeof(cnt));
		for (int i = 0; i < V; i++)
			d[i] = INF;
		d[s] = 0;
		inq[s] = true;
		Q.push(s);
		while (!Q.empty()) {
			int u = Q.front();
			Q.pop();
			inq[u] = false;
			for (int i = 0; i < G[u].size(); i++) {
				Edge& e = edges[G[u][i]];
				if (d[u] < INF && d[e.to] > d[u] + e.dist) {
					d[e.to] = d[u] + e.dist;
					p[e.to] = G[u][i];
					if (!inq[e.to]) {
						Q.push(e.to);
						inq[e.to] = true;
						if (++cnt[e.to] > V)
							return false;
					}
				}
			}
		}
		return true;
	}
};

Dijkstra solve;

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in29.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int s, t, d;
	cin >> V >> E >> r;
	solve.init(V);
	for (int i = 0; i < E; i++) {
		scanf("%d%d%d", &s, &t, &d);
		solve.AddEdge(s, t, d);
	}
	if (solve.bellman_ford(r)) {
		for (int i = 0; i < V; i++) {
			if (solve.d[i] == INF)
				cout << "INF" << endl;
			else
				cout << solve.d[i] << endl;
		}
	}
	else
		cout << "NEGATIVE CYCLE" << endl;
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 6112
n, A, B, c = list(map(int, input().split()))

MOD = 10**9+7
MAX = 200000
fact = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]
invfact = [0 for i in range(MAX)]

def comb_build(n):
  fact[0] = inv[0] = invfact[0] = 1
  fact[1] = inv[1] = invfact[1] = 1
  for i in range(2, n):
    fact[i] = fact[i-1]*i%MOD
    inv[i] = inv[MOD%i]*(MOD-MOD//i)%MOD
    invfact[i] = invfact[i-1]*inv[i]%MOD

def nCk(n, k):
  if n<k or n<0 or k<0:
    return 0
  return (((fact[n]*invfact[k])%MOD)*invfact[n-k])%MOD

comb_build(MAX)

ans = 0
a = A*pow(A+B, MOD-2, MOD)%MOD
b = B*pow(A+B, MOD-2, MOD)%MOD
c = 100*pow(100-c, MOD-2, MOD)%MOD

for i in range(n, 2*n):
  t1 = pow(a, n, MOD)%MOD*pow(b, i-n, MOD)%MOD
  t2 = pow(a, i-n, MOD)%MOD*pow(b, n, MOD)%MOD
  ans += nCk(i-1, n-1)*(t1+t2)%MOD*i*c%MOD
  ans %= MOD

print(ans)

Measured memory_bytes: 57680
"use strict";

function compareFunc(a, b) {
  return a - b;
}
const main = arg => {
  const input = arg.trim().split("\n");
  const N = parseInt(input[0].split(" ")[0]);
  const K = parseInt(input[0].split(" ")[1]);
  const ps = input[1].split(" ").map(x => parseInt(x));
  ps.sort(compareFunc);
  let ret = 0
  for (let i = 0; i < K; i++) {
    ret += ps[i];
  }
  console.log(ret);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;


    


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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<map>

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vii;

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

ll bpow(int n) {
	ll x = 1;
	for (int i = 1; i <= n; i++) {
		x *= 2;
	}
	return x;
}

void solve() {

	int N;
	cin >> N;

	int cx, cy;
	vi x(N), y(N), h(N);
	REP(i, N) {
		cin >> x[i] >> y[i] >> h[i];
	}
	int H = 0;
	bool find = false;
	for (cx = 0; cx <= 100; cx++) {
		for (cy = 0; cy <= 100; cy++) {
			int i;
			for (i = 0; i < N; i++) {
				if (h[i] != 0) {
					H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
					break;
				}
			}
			for (i = 0; i < N; i++) {
				int absx = abs(x[i] - cx);
				int absy = abs(y[i] - cy);
				if (h[i] != 0) {
					if (H != h[i] + absx + absy) break;
				}
				else {
					if (H > absx + absy) break;
				}
			}
			if (i == N) {
				cout << cx << " " << cy << " " << H << endl;
				find = true;
				break;
			}
		}
		if (find) break;
	}

	return;

}

int main() {

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

	solve();

	return 0;

}

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

int main() {
  
  int N, A, B, Ans;
  cin >> N;
  cin >> A;
  while( A%2==0){
    B +=1;
    A /=2;
  }
  Ans = B; 
  for (int i = 0; i < N-1; i++){
    cin >> A;
    B = 0;
    while( A%2==0){
      B +=1;
      A /=2;
    }
    if (Ans > B){
      Ans = B;
    }
  }
  cout << Ans <<endl;    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
char str[10000];
int n;
int solve(){
    for(int i=0;i<n/2;i++)
            if(str[i]!=str[i+n/2])return 0;
            return 1;
}
int main()
{
    cin>>n;
    cin>>str;
    if(n%2==1)cout<<"No";
    else{
        if(solve())cout<<"Yes";
        else cout<<"No";
    }
    return 0;
}


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

int main(){
  string s;
  cin>>s;
  
  ll a=0,b=0;
  rep(i,s.size()){
    if(s[i] == 'W'){
      a += i;
      b++;
    }
  }
  
  ll res = b*(b-1)/2;
  cout << a - res << endl;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  int L,R;
  L = A + B;
  R = C + D;
  
  if (L > R)
    cout << "Left" << endl;
  else if (L == R)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}


Measured memory_bytes: 256
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7



def main():
  s = input()
  dic = {}
  i = 0
  while i != len(s):
    if not s[i] in dic.keys():
      dic[s[i]] = 1
    else:
      print('no')
      exit()
    i +=1
  print('yes')
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e9;
const int MOD = INF+7;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define MP make_pair
#define pb(n) push_back(n)
using P = pair<int,int>;
signed main(){
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i,N) cin >> P[i];
    vector<int> seqlen(N+1,0);
    int MAX = 0;
    rep(i,N){
        seqlen[P[i]] = seqlen[P[i]-1] + 1;
        MAX = max(MAX,seqlen[P[i]]); 
    }
    cout << N - MAX << endl;
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<stdlib.h>
int compar(const int *val1, const int *val2);
int main(void){
	int a[3],sum;
	int n=sizeof(a)/sizeof(a[0]);
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	    qsort(a, n, sizeof(int),
        (int (*)(const void *, const void *))compar
    );
	sum=a[2]-a[0];
	printf("%d",sum);
	return EXIT_SUCCESS;
}



int compar(const int *val1, const int *val2) {
    if ( *val1 < *val2 ) {
        return -1;
    } else if ( *val1 == * val2 ) {
        return 0;
    } else {
        return 1;
    }
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = Integer.parseInt(sc.next());
		sc.close();
		if((X == 3) || (X == 5) | (X == 7)) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}

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

using namespace std;

using ll = long long;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
    cin.tie(0);
    cout << fixed << setprecision(10);

    int n; cin >> n;
    map<pair<int, int>, int> mp;
    vector<pair<int, int>> p;
    for(int i=0;i<n;++i) {
      int x, y, w;
      cin >> x >> y >> w;
      mp[{x, y}] = w;
      p.push_back({x, y});
    }

    int ans = 0;
    for(int i=0;i<n;++i) {
      int x = p[i].first, y = p[i].second;
      ans = max(ans, mp[{x, y}] + mp[{x+1, y}] + mp[{x, y+1}] + mp[{x+1, y+1}]);
      ans = max(ans, mp[{x, y}] + mp[{x+1, y}] + mp[{x, y-1}] + mp[{x+1, y-1}]);
    }
    cout << ans << " / 1" << endl;
}


Measured memory_bytes: 41108
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


int64_t count_bottom(int W, int H, int K) {
    int64_t answer = 0;

    for (int s = 0; s < H - 1; s++)
        for (int x = 1; x < W && x * s <= 2 * K + W - 2; x++) {
            int R = 2 * K - 2 - x * s + __gcd(W, s);

            if (R >= 0) {
                int y = min(R / W + 1, H - s - 1);
                assert(0 < y && y + s < H);
                int success = W * y - __gcd(x, y) - __gcd(W - x, y + s) <= R;
                success += y - 1;
                answer += (s == 0 ? 1 : 2) * success;
            }
        }

    return answer;
}

int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    int W, H, K;
    cin >> W >> H >> K;
    cout << 2 * count_bottom(W, H, K) + 2 * count_bottom(H, W, K) << '\n';
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
 
char s[105];int l,ans=1e9;
 
int main()
{
    scanf("%s",s),l=strlen(s);
    for(int i=0,t,k;i<26;++i)
    {
	t=k=-1;
	for(int j=0;j<l;++j)
	    if(s[j]=='a'+i)k=std::max(k,j-t-1),t=j;
	ans=std::min(ans,std::max(k,l-t-1));
    }
    printf("%d\n",ans);
    
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int []A = nextIntArray(N);
		int []B = nextIntArray(N);
		int []C = nextIntArray(N-1);

		int res = 0;
		for(int i=0;i<N;i++) {
			res += B[A[i]-1];
			if(i>0 && A[i-1]==A[i]-1) {
				res += C[A[i-1]-1];
			}
		}

		out.println(res);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

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

template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}

main()
{
        int K; cin>>K;
        long ans=0;

        for(int i=1;i<=K;i++)
        {
                for(int j=1;j<=K;j++)
                {
                        for(int k=1;k<=K;k++)
                        {
                                ans+=gcd(i,gcd(j,k));
                        }
                }
        }
        cout<<ans<<endl;

}


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

#define ll long long
#define ull unsigned ll

#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define INFLL 9e18
#define INF 2e9
#define EPS 1e-9
#define pb push_back
#define emp emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define DEBUG 0


int main ()

{
    #define int ll
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout.tie(NULL);

    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    
    int d1, m1, d2, m2;
    cin >> m1 >> d1 >> m2 >> d2;
    if (m1 == 2){
        if (d1 == 28) cout << 1 << endl;
        else cout << 0 << endl;
    }
    else if (m1 == 1 || m1 == 3 || m1 == 5 || m1 == 7 || m1 == 8 || m1 == 10 || m1 == 12){
        if (d1 == 31) cout << 1 << endl;
        else
        {
             cout << 0 << endl;
        }
        
    }
    else{
        if (d1 == 30) cout << 1 << endl;
        else cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * 1389.cc: Digits Are Not Just Characters
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef pair<int,int> pii;
typedef vector<pii> vpii;

enum { NUM, LTR };

/* global variables */

char s[16];

/* subroutines */

void parse(char s[], vpii &f) {
  f.clear();
  for (char *cpt = s; *cpt;) {
    if (*cpt >= '0' && *cpt <= '9') {
      int num = 0;
      while (*cpt >= '0' && *cpt <= '9')
	num = num * 10 + (*(cpt++) - '0');
      f.push_back(pii(NUM, num));
    }
    else
      f.push_back(pii(LTR, (int)*(cpt++)));
  }
}

bool ltvpii(const vpii &a, const vpii &b) {
  int na = a.size(), nb = b.size(), n = min(na, nb);

  for (int i = 0; i < n; i++)
    if (a[i] != b[i]) return (a[i] < b[i]);
  return (na < nb);
}

/* main */

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

  vpii f0;
  parse(s, f0);

  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    vpii f;
    parse(s, f);
    if (ltvpii(f, f0)) puts("-");
    else puts("+");
  }
  return 0;
}



Measured memory_bytes: 3172
N=int(input())
A=list(map(int,input().split()))
pos=A[0]
add=0
for i in range(N):
    diff=pos-A[i]
    if  diff>0:
        add=add+pos-A[i]
        pos=A[i]+diff
    else:
        pos=A[i]
print(add)

Measured memory_bytes: 32056
#include<stdio.h>
#include<stdlib.h>
int p=0,S[100];
int main()
{
	void push(int x);
	int pop(),a,b;
	char s[10];
	while(scanf("%s",s)!=EOF)
	{
		if(s[0]=='+')
		{
			b=pop();
			a=pop();
			push(a+b);
		}
		else if(s[0]=='-')
		{
			b=pop();
			a=pop();
			push(a-b);
		}
		else if(s[0]=='*')
		{
			b=pop();
			a=pop();
			push(a*b);
		}
		else
		{
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	return 0;
}
void push(int x)
{
	S[++p]=x;
}
int pop()
{
	p--;
	return(S[p+1]);
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    ll a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
#define ll long long 
inline ll read()
{
    ll x=0,t=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-') t=-1,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return x*t;
}
ll a,b;
inline ll gcd(ll a,ll b)
{
	return b?gcd(b,a%b):a;
}
int main ()
{
	a=read(),b=read();
	ll c=gcd(a,b);
	ll ans=1;
	for(ll i=2;i*i<=c;i++)
	{
		if(c%i==0)
		{
			ans++;
			while(c%i==0) c/=i;
		}
	}
	if(c!=1) ans++;
	printf("%lld\n",ans);
	return 0;
}


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





public class Main {

    static MyScanner in = new MyScanner();
    static   PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    int N;
    static int max = 200001;
    static int [] dr = {1,-1,0,0};
    static int [] dc={0,0,-1,1};
    static boolean [][] grid;
    static int [] bishopr = {-1,1,-1,1};
    static int [] bishopc = {1,1,-1,-1};
    static long H,W,cnt;
    public static void main(String args[]) throws IOException {
            int [][] grid  = new int[3][3];
            for(int i=0;i<3;i++)
                for(int j=0;j<3;j++)
                grid[i][j]= in.nextInt();
            int N =in.nextInt();
            for(int k=0;k<N;k++){
                int  p = in.nextInt();
                for(int i=0;i<3;i++)
                for(int j=0;j<3;j++)
                if(grid[i][j] ==p)
                grid[i][j] =  -1;
            }
            boolean yes = false;
            //stop
            for(int i=0;i<3;i++){
                int count =0;
                for(int j=0;j<3;j++){
                    if(grid[i][j]==-1)
                    count++;
                }
                if(count==3)
                yes = true;
            }
            for(int i=0;i<3;i++){
                int count =0;
                for(int j=0;j<3;j++){
                    if(grid[j][i]==-1)
                    count++;
                }
                if(count==3)
                yes = true;
            }
            if((grid[0][0]==grid[1][1])&&grid[1][1]==grid[2][2]){
                yes = true;
            }
            if((grid[0][2]==grid[1][1])&&(grid[1][1]==grid[2][0])){
                yes = true;
            }
            out.println(yes?"Yes":"No");
        out.flush();
        }   

        static boolean isEven(long a) {
            return (a&1)==0;
        }
       static  void swap (int a, int b){

        int temmp = b;
        b=a;
        a = temmp;
        }
    

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
}

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

int min(int x,int y){
  if(x<y) return x;
  return y;
}

int max(int x,int y){
  if(x>y) return x;
  return y;
}

const int INF = 1001000000;

int main(){
  int n,a,maximum = -INF,minimum = INF;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    maximum=max(maximum,a);
    minimum=min(minimum,a);
    }
  cout << maximum-minimum << endl;
}


Measured memory_bytes: 256
#解説より
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
	t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])

Measured memory_bytes: 7748
#include <iostream>
using namespace std;
#define CIN(n) int n; cin>>(n);
int main()
{
	CIN(A);
	CIN(B);
	long long int c;
	if (B == 100) {
		c = 101;
		if (A == 1)c = 10100;
		if (A == 2)c = 1010000;
		cout << c;
	}else{
	c = B;
	if (A== 0)
		cout << B;
	else {
		for (int i = 0; i < 2 * A; i++)
			c = c * 10;
		cout << c;
	}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int i;
        for (i = 0; i < n ; i++) {
            if(s.substring(i, s.length()).equals(t.substring(0, t.length()-i))) break;
        }
        System.out.println((n+i));
    }
}


Measured memory_bytes: 9812
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  
  int l[55];
  for (int i = 0; i < N; i++){
    cin >> l[i];
  }
  
  sort(l, l + N, greater<int>());
  int ans = 0;
  for (int i = 0; i < K; i++){
    ans += l[i];
  }
  cout << ans << endl;
 
}

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

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, M = MAP()

a = LIST()

for i in range(1, N):
	if abs(a[0]//2-a[i]//2) % gcd(a[0], a[i]) != 0:
		print(0)
		sys.exit()
tmp = 1
for x in a:
	tmp = x//2*tmp//gcd(x//2, tmp)
print((M-tmp)//(tmp*2)+1)


Measured memory_bytes: 16292
#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7, N = 2e5 + 5;

template <int MOD=1000000007>
struct Modular {
  int value;
  static const int MOD_value = MOD;

  Modular(long long v = 0) { value = v % MOD; if (value < 0) value += MOD;}
  Modular(long long a, long long b) : value(0){ *this += a; *this /= b;}

  Modular& operator+=(Modular const& b) {value += b.value; if (value >= MOD) value -= MOD; return *this;}
  Modular& operator-=(Modular const& b) {value -= b.value; if (value < 0) value += MOD;return *this;}
  Modular& operator*=(Modular const& b) {value = (long long)value * b.value % MOD;return *this;}

  friend Modular mexp(Modular a, long long e) {
    Modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
    return res;
  }
  friend Modular inverse(Modular a) { return mexp(a, MOD - 2); }

  Modular& operator/=(Modular const& b) { return *this *= inverse(b); }
  friend Modular operator+(Modular a, Modular const b) { return a += b; }
  friend Modular operator-(Modular a, Modular const b) { return a -= b; }
  friend Modular operator-(Modular const a) { return 0 - a; }
  friend Modular operator*(Modular a, Modular const b) { return a *= b; }
  friend Modular operator/(Modular a, Modular const b) { return a /= b; }
  friend std::ostream& operator<<(std::ostream& os, Modular const& a) {return os << a.value;}
  friend bool operator==(Modular const& a, Modular const& b) {return a.value == b.value;}
  friend bool operator!=(Modular const& a, Modular const& b) {return a.value != b.value;}
};

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n, k;
  cin >> n >> k;

  k = min(n-1, k);
  Modular<M> ans = 0, fact[N];

  fact[0] = 1;
  for (int i = 1; i < N; ++i)
    fact[i] = fact[i-1] * i;

  for (int i = 0; i <= k; ++i) {
    Modular<M> cur = fact[n] / (fact[i] * fact[n-i]);
    cur *= fact[n-1] / (fact[n-i-1] * fact[i]);
    ans += cur;
  }

  cout << ans << '\n';
}



Measured memory_bytes: 1024
n = int(input())
s = str(input())
r = []
g = []
def right(r,g):
    return (max(r,g)+(abs(r-g)))
def left(r,g):
    return (min(r,g)-(abs(r-g)))
def half(r,g):
    return ((r+g)//2)
for i in range(n):
    if s[i] == "R":
        r.append(i)
    elif s[i] == "G":
        g.append(i)
ans = len(r)*len(g)*(n-(len(r)+len(g)))
for i in range(len(r)):
    for j in range(len(g)):
        t = left(r[i],g[j])
        f = right(r[i],g[j])
        h = half(r[i],g[j])
        if f < n:
            if s[f] == "B":
                ans -= 1
        if 0 <= t:
            if s[t] == "B":
                ans -= 1
        if abs(r[i]-g[j])%2 == 0:
            if s[h] == "B":
                ans -= 1
print(ans)

Measured memory_bytes: 70012
#include<stdio.h>
#include<math.h>
#define N 10000
int isPrime(int x);
int main()
{
  int n,C[N],j,cnt=0,i;

  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    {
      scanf("%d",&C[i]);
      if(isPrime(C[i]) == 1)cnt++;
    }
  printf("%d\n",cnt);

  
  return 0;  
}

int isPrime(int x)
{
  int j,i;
  if(x == 2)return 1;
    if(x<2 || x%2 == 0)return 0;

    i=3;
    while(i<=sqrt(x))
      {
	if(x%i == 0)return 0;
	i=i+2;
      }
	  
    return 1;
}



Measured memory_bytes: 2144
mod = 10**9+7
H, W, K = map(int, input().split())

D = [[0]*W for _ in range(W)]
for S in range(1<<W-1):
    if S & S<<1 != 0:
        continue
    #print(bin(S))
    S <<= 1
    for i in range(W):
        if S>>i&1:
            D[i][i-1] += 1
        elif S>>i+1&1:
            D[i][i+1] += 1
        else:
            D[i][i] += 1
    #for d in D:
    #    print(d)

E = [[0]*W for _ in range(W)]
for i in range(W):
    E[i][i] = 1

for i in range(H):
    A = [[0]*W for _ in range(W)]
    for x in range(W):
        for y in range(W):
            A[x][y] = sum(E[x][z] * D[z][y] % mod for z in range(W)) % mod
    E = A

print(A[0][K-1])


Measured memory_bytes: 3064
N = int(input())
A = [int(_) for _ in input().split()]

cnt = 0
m = 1e10
ans = 0
for a in A:
    if a < 0:
        cnt += 1
    ans += abs(a)
    m = min(abs(a), m)
if cnt % 2 == 0:
    print(ans)
else:
    print(ans - m*2)

Measured memory_bytes: 14332
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
const double pi=3.1415926535897932384626;
int main(){
    itn n,m;
    std::cin >> n>>m;
    std::cout << n*(n-1)/2+m*(m-1)/2 << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n,l;
	cin>>n>>l;

	string s[n];

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

	sort(s,s+n);

	for(int i=0;i<n;i++){
		cout<<s[i];
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const int INF=1000100010;
int main(){
    int x;cin>>x;
    int count=0;
    while(x>=500){
        count+=1000;
        x-=500;
     }
    
    while(x>=5){
        count+=5;
        x-=5;
     }
    
cout<<count<<endl;
}

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

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

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

    bool ok = false;
    for (int i = 1; i < 10; i++)
        for (int j = 1; j < 10; j++)
            if (i * j == n)
                ok = true;

    printf("%s\n", ok ? "Yes" : "No");

    return 0;
}


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

# RUN LENGTH ENCODING
def rfe_tupple(S: str):
    grouped = groupby(S)
    res = []
    for k, v in grouped:
        res.append((k, str(len(list(v)))))
    return res

def main():
    S = input()
    N = len(S)
    
    now = 0
    compressed = rfe_tupple(S)
    ans = [0] * N
    for lr, i in compressed:
        i = int(i)
        if lr == "R":
            now += i
            ans[now - 1] += i - i // 2
            ans[now] += i // 2
        else:
            ans[now - 1] += i // 2
            ans[now] += i - i // 2
            now += i
    
    L = [str(i) for i in ans]
    print(" ".join(L))
    return

if __name__ == '__main__':
    main()


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

using namespace std;

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

  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }
  double ans = 0, cur = 0;
  for (int i = 0; i < k; ++i) {
    cur += (p[i] + 1) / 2.0;
  }
  ans = cur;
  for (int i = k; i < n; ++i) {
    cur -= (p[i - k] + 1) / 2.0;
    cur += (p[i] + 1) / 2.0;
    ans = max(ans, cur);
  }
  cout << fixed << setprecision(20) << ans;

  return 0;
}

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

int sub(int tmp, int a, int b)
{
        int sum = 0;

        while(tmp){
                sum += (tmp % 10);
                if(sum > b)
                        return 0;
                tmp /= 10;
        }

        return sum < a ? 0 : 1;
}

int main(void)
{
        int n, a, b, tmp = 0, sum = 0;

        scanf("%d %d %d", &n, &a, &b);

        while(++tmp <= n){
                sum += sub(tmp, a, b) ? tmp : 0;
        }

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

        return 0;
}


Measured memory_bytes: 128
from operator import itemgetter

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

AB = []
for i in range(N):
    AB.append(list(map(int, input().split())))

AB.sort(key=itemgetter(0, 1))

ct = 0
money = 0
for i in AB:
    A, B = i[0], i[1]
    money += A*B
    ct += B
    if ct >= M:
        money -= (ct - M)*A
        break

print(money)


Measured memory_bytes: 35372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long double PI = 3.14159265358979323846;

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

    int n, m;
    cin >> n >> m;
    vector<vector<string>> sub(n);
    int c = 0, p = 0;
    for (int i = 0; i < m; ++i) {
        int key;
        string verd;
        cin >> key >> verd;
        sub[key - 1].push_back(verd);
    }
    for (int i = 0; i < (int)sub.size(); ++i) {
        int j = 0;
        int local = sub[i].size(), delta = 0;
        while (j < local) {
            if (sub[i][j] == "AC") {
                p += delta;
                ++c;
                break;
            }
            ++delta;
            ++j;
        }
    }
    cout << c << ' ' << p << '\n';

    return 0;
}


Measured memory_bytes: 10368