akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int64_t> A(n);
    for (int i = 0; i < n; i++) cin >> A[i];

    int64_t ans = 0, mi = int(1e10);
    int cnt_minus = 0;
    int is_zero = false;

    for (const auto &a: A) {
        if (a < 0) cnt_minus++;
        if (a == 0) is_zero = true;
        ans += abs(a);
        mi = min(abs(a), mi);
    }

    cout << ans - 2 * ((is_zero or cnt_minus % 2 == 0) ? 0 : mi) << endl;
}

Measured memory_bytes: 1024
use proconio::{input, marker::Usize1};

struct Graph {
    size: usize,
    mat: Vec<Vec<bool>>,
    visited: Vec<bool>,
    ab: Vec<(usize, usize)>,
}

impl Graph {
    fn new(n: usize, ab: Vec<(usize, usize)>) -> Self {
        let mut mat = vec![vec![false; n]; n];
        let visited = vec![false; n];
        let size = n;
        for &(a, b) in ab.iter() {
            mat[a][b] = true;
            mat[b][a] = true;
        }
        Self { size, mat, visited, ab }
    }

    fn dfs(&mut self, x: usize) {
        self.visited[x] = true;
        for i in 0..self.size {
            if !self.visited[i] && self.mat[x][i] {
                self.dfs(i);
            }
        }
    }

    fn solve(&mut self) -> usize {
        let mut count = 0;
        for i in 0..self.ab.len() {
            for e in self.visited.iter_mut() {
                *e = false;
            }
            self.mat[self.ab[i].0][self.ab[i].1] = false;
            self.mat[self.ab[i].1][self.ab[i].0] = false;
            self.dfs(0);

            if self.visited.iter().any(|&x| x == false) {
                count += 1;
            }
    
            self.mat[self.ab[i].0][self.ab[i].1] = true;
            self.mat[self.ab[i].1][self.ab[i].0] = true;
        }
        count
    }
}

fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(Usize1, Usize1); m],
    }

    let mut graph = Graph::new(n, ab);

    let ans = graph.solve();

    println!("{}", ans);
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  string s;cin>>s;
  n=n%26;
  for(int i=0;i<s.size();i++)
  {
    s[i]+=n;
    if(s[i]>'Z')
      s[i]-=26;
  }
  cout<<s<<endl;
  return 0;
}

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


class Program
{
    public void Proc()
    {


        Reader.IsDebug = false;
        long prev = 0;

        int inputCount = int.Parse(Reader.ReadLine());

        long ans = 0;
        for (int i = 0; i < inputCount; i++)
        {
            long num = long.Parse(Reader.ReadLine());

            if (num > 0)
            {
                ans += (num + prev) / 2;
                prev = (num + prev) % 2;

            }
            else
            {
                prev = 0;
            }
        }
        Console.WriteLine(ans);
 


    }



    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"


8
2
0
1
6
0
8
2
1


";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 6744
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(Int (i) = 0; (i) < (n); (i)++)
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr Uint mod = 1e9 + 7;
constexpr Int Int_max = LLONG_MAX;
constexpr Int Int_min = LLONG_MIN;
using Container = vector<Int>;
using Grid = vector<vector<char>>; // [y][x]


int main() {

	Int N, M; cin >> N >> M;
	if (N == M)cout << "Yes";
	else cout << "No";

}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int N;
    cin >> N;

    vector<ll> v(N), c(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> c[i];
    }

    ll X = 0, Y = 0, ans = -1;
    for (int i = 0; i < (1 << N); i++) {
        X = 0; Y = 0;
        for (int j = 0; j < N; j++) {
            if ((i >> j) & 1) {
                X += v[j];
                Y += c[j];
            }
        }
        ans = max(ans, X - Y);
    }

    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {

  val a = StdIn.readLine().split(" ").map(_.toInt)
  
  def judge(n: Int) = n > 0 && n % 3 == 0 
  
  println(if(judge(a(0)) || judge(a(1)) || judge(a.sum)) "Possible" else "Impossible")
  
}


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

int main()
{  
	int c[30] = {};
	string str;
	while (cin >> str)
	{
		for (int i = 0; i < str.size(); i++)
		{
			if ('a' <= str[i] && str[i] <= 'z')
			{
				c[str[i] - 'a']++;
			}
			if ('A' <= str[i] && str[i] <= 'Z')
			{
				c[str[i] - 'A']++;
			}
		}
	}
	for (int i = 0; i < 26; i++)
	{
		cout << char('a' + i) << " : " << c[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



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

	if (n <= 5)b = 0;
	if (n <= 12)b /= 2;
	cout << b << endl;

	return 0;



}

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

int main() {
    int K,n;
    cin >> K >> n;
    int A[n];
    rep(i,0,n) cin >> A[i];
    int max_dist = K-A[n-1]+A[0];
    rep(i,0,n-1) max_dist = max(A[i+1]-A[i],max_dist);
    cout << (K-max_dist) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 

const int mod = 1000000007;
const int inf = 1e9;

int main(){
    long double l;
    cin >> l;
    cout << setprecision(16)<< pow(l/3, 3);

}

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

float han(float a, float b, float c, float d){
	return (d - b) / (c - a);
}

int main(){
	int n;
	float ax, ay, bx, by, cx, cy, dx, dy, A, B;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;
		if(ax == bx && cx == dx){
			cout << "YES" << endl;
			continue;
		}
		if(ax == bx || cx == dx){
			cout << "NO" << endl;
			continue;
		}
		A = han(ax, ay, bx, by);
		B = han(cx, cy, dx, dy);
		if (A==B){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

int main(){
int i, j, k, H, W, N=10, ans=0; cin >> H >> W; int c[N][N];
for(i=0; i<N; i++){for(j=0; j<N; j++){ cin >> c[i][j]; }}
for(k=0; k<N; k++){for(i=0; i<N; i++){for(j=0; j<N; j++){ c[i][j]=min(c[i][j], c[i][k]+c[k][j]); }}}
for(i=0, k=0; i<H; i++){for(j=0; j<W; j++){ cin >> k; if(k!=-1){ans+=c[k][1];} }}
cout << ans << "\n";    
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main(void)
{
 
  int n,b,m,i,j;
  cin >> n;
  for(i = 1;i <= 6;i++)
  {
  	if(pow(10,i) > n)
      break;
  }
  
  switch(i)
  {
    case 1:
      m = n;
      break;
    case 2:
      m = 9;
      break;
    case 3:
      m = 9 + n - 100 + 1;
      break;
    case 4:
      m = 9 + 900;
      break;
    case 5:
      m = 9 + 900 + n - 10000 + 1;
      break;
    case 6:
      m = 9 + 900 + 90000;
      break;
  }
  cout << m;
  return 0;
}

Measured memory_bytes: 256
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

a,b = map(int,input().split())
s = input()
num = ["0","1","2","3","4","5","6","7","8","9"]
if s[a] != "-":
    print("No")
    sys.exit()
for i in range(len(s)):
    if i == a:
        continue
    if s[i] not in num:
        print("No")
        sys.exit()
print("Yes")

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

public class Main {

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

        final int N = sc.nextInt();
        final int K = sc.nextInt();

        final int[] p = new int[N];
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }

        Arrays.sort(p);

        System.out.println(Arrays.stream(p).limit(K).sum());
    }
}


Measured memory_bytes: 39416
A,B,M=map(int,input().split())
a=[0]+list(map(int,input().split()))
b=[0]+list(map(int,input().split()))
xyc=[list(map(int,input().split())) for i in range(M)]
ans=min(a[1:])+min(b[1:])
for i in range(M):
  ans=min(ans,a[xyc[i][0]]+b[xyc[i][1]]-xyc[i][2])
print(ans)

Measured memory_bytes: 39184
#include <bits/stdc++.h>
using namespace std;
long double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998626034825342117;
int main(){
  long double A,B,N; cin>>A>>B>>N;N/=A;
  if(A*B/2<=N)cout<<fixed<<setprecision(15)<<atan2(((A*B-N)*2),A*A)*180/PI<<endl;
  else cout<<fixed<<setprecision(15)<<atan2(B*B,N*2)*180/PI<<endl;
}

Measured memory_bytes: 3832
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	int a,b;
	char x[40];
	cin>>a>>b>>x;
	if(strlen(x)!=a+b+1||x[a]!='-'){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<a+b;i++)
	if(i!=a&&(x[i]>'9'||x[i]<'0')){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
int main(){
  int a,b,c;
  int tmp;
  std::cin >> a >> b >> c;
  if(a>c){
    tmp = a;
    a = c;
    c = tmp;
  }
  if(a>b){
    tmp = a;
    a = b;
    b = tmp;
  }
  if(b>c){
    tmp = b;
    b = c;
    c = tmp;
  }

  std::cout << a << " "<< b << " " << c <<std::endl;
}


Measured memory_bytes: 3072
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<limits>
#include<queue>
#include<stack>
#include<math.h>
#include<array>
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;
int main(){
    int N;
    cin >> N;
    if(N==25){
        cout <<"Christmas" << endl;
    }
    if(N == 24){
        cout <<"Christmas Eve" << endl;
    }
    if(N == 23){
        cout <<"Christmas Eve Eve" << endl;
    }
    if(N == 22){
        cout <<"Christmas Eve Eve Eve" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;


signed main() {
	ios::sync_with_stdio(false);
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int i, j, k;
	int defAcost = a * x;
	int defBcost = b * y;
	int myAB = 0;
	int minAcost = defAcost;
	int minBcost = defBcost;
	int ans = minAcost + minBcost;
	for (int i = 0; i < (x + y) * 2; i += 2) {
		int costA = a * (x - i / 2);
		int costB = b * (y - i / 2);
		if (costA < minAcost and costB < minBcost and costA >= 0 and costB >= 0) {
			minAcost = costA;
			minBcost = costB;
			myAB = i;
			ans =  min(ans,a * (x - myAB / 2) + b * (y - myAB / 2) + c * myAB);
		}
	}
	int allABcost = c * max(x, y) * 2;
	cout << min(allABcost,ans) << '\n';
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = []
for i in range(N):
    a.append(int(input())//10)
    
max_dist = 0

for i in range(N):
    if max_dist >= i:
        max_dist = max(max_dist, i + a[i])

if max_dist >= N-1:
    max_dist = 0
    for i in range(N):
        if max_dist >= i:
            max_dist = max(max_dist, i + a[N-1-i])

    if max_dist >= N-1:
        print("yes")
    else:
        print("no")

else:
    print("no")
    


Measured memory_bytes: 17368
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		
		RaddQ rq = new RaddQ(n);
		
		for (int i = 0; i < q; i++) {
			int command = sc.nextInt();
			if(command == 0){
				int s = sc.nextInt();
				int t = sc.nextInt();
				int x = sc.nextInt();
				rq.add(0,n,0,s-1,t,x);
			} else if (command == 1) {
				int t = sc.nextInt();
				System.out.println(rq.get(0,n,0,t-1));
			}
		}
	}
}


class RaddQ { 
	int n, heap[];
	
	RaddQ(int n){
		this.n = n;
		
		int len = 1;
		while(len < n){
			len*=2;
		}
		len = 2*len;
		heap = new int[len];
	}
	

	
	void add(int l, int r, int ih, int s, int t, int x){
		if(s>=t){
			return;
		}
		if(s==l && t==r){
			heap[ih] += x;
			return;
		}
		int med = (l+r)/2;
		add(l, med, ih*2+1, Math.max(s,l), Math.min(t,med), x);
		add(med, r, ih*2+2, Math.max(s,med), Math.min(t,r), x);
	}
	
	
	int get(int l, int r, int ih, int t){
		if(r-l == 1){
			return heap[ih];
		}
		int med = (l+r)/2;
		if(t<med){
			return heap[ih]+get(l, med, ih*2+1, t);
		} else {
			return heap[ih]+get(med, r, ih*2+2, t);
		}
	}
}


Measured memory_bytes: 105420
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	int n = s.length();
	int left[n+1], right[n+1];
	int cnt = 0;
	left[0] = 0, right[n] = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '<') cnt++;
		else cnt = 0;
		left[i+1] = cnt;
	}
	cnt = 0;
	for(int i = n-1; i >= 0; i--){
		if(s[i] == '>') cnt++;
		else cnt = 0;
		right[i] = cnt;
	}
	long long ans = 0;
	for(int i = 0; i < n+1; i++){
		ans += max(left[i], right[i]);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> nums;
    rep(i, max(a, b)){
        if (a%i == 0 && b%i == 0) nums.push_back(i);
    }
    reverse(nums.begin(), nums.end());
    cout << nums[k-1] << endl;
    return 0;
}

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

using namespace std;

int main(void){
	int n;

	cin >> n;

	vector<int> a(n);

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


	for (int i = n-1; i >= 0; i -= 2){
		cout << a[i] << " ";
	}


	int k;
	if (n % 2 == 0)
		k = 0;
	else
		k = 1;

	for (int i = k; i < n; i += 2){
		cout << a[i] << " ";
	}

}

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

int comp(const void *p,const void *q){
  return *(int*)p-*(int*)q;
}

int dgt(int n){
  if(n==0){
    return 0;
  }
  else{
    return 1+dgt(n/10);
  }
}

int mlten(int n){
  if(n==0){
    return 1;
  }
  else{
    return 10*mlten(n-1);
  }
}

int fixit(int a,int b){
  return b+a*mlten(dgt(b));
}

void doit(){
  int n;
  scanf("%d",&n);
  {
    int i,j;
    int a[n];
    int fst=1000000000,scd=1000000000,thd=1000000000;
    for(i=0;i<n;i++){
      scanf("%d",&a[i]);
    }
    qsort(a,n,sizeof(int),comp);
    
    for(i=0;i<n;i++){
      int lmt;
      if(n==3){
	lmt=3;
      }
      else{
	lmt=4;
      }
      for(j=0;j<lmt;j++){
	if(i!=j){
	  int tmp=fixit(a[i],a[j]);
	  if(tmp<=thd){
	    thd=tmp;
	    if(tmp<=scd){
	      thd=scd;
	      scd=tmp;
	      if(tmp<=fst){
		scd=fst;
		fst=tmp;
	      }
	    }
	  }
	}
      }
    }
    printf("%d\n",thd);
  }
}

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

Measured memory_bytes: 700
#include <stdio.h>
int main(void){

  unsigned long	L,R,i,j;
  unsigned long	tmp,ans;
  unsigned long	min	  =2000000000;
  unsigned long	min_i =0;
  
  scanf("%lu %lu", &L, &R);
  
  //各々一番近いところでおｋ
  if( (R-L) >= 2019 ){
    ans = 0;
    printf("%lu", ans);
  }
  
  else{
    for( i=L; i<R; i++ ){
      for( j=R; j>i; j-- ){
        tmp = (i*j)%2019;
        if( tmp < min ){ min = tmp; }
      }
    }
    printf("%lu",min);
  }
  return 0;
}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

const int MAX = 100 + 5;
char mat[MAX][MAX];

int main() {
	ios_base::sync_with_stdio(false);

	int a, b;
	cin >> a >> b;

	bool swapped = false;
	if(b > a) {
		swap(a, b);
		swapped = true;
	}

	memset(mat, '#', sizeof mat);
	fori(i, 51, 100 + 1) {
		fori(j, 1, 100 + 1) {
			mat[i][j] = '.';
		}
	}

	int used_a = 1, used_b = 1;

	for(int i = 1; used_a < a && i <= 50; i += 2) {
		for(int j = 1; used_a < a && j <= 100; j += 2) {
			mat[i][j] = '.';
			used_a++;
		}
	}

	for(int i = 100; used_b < b && i >= 51; i -= 2) {
		for(int j = 1; used_b < b && j <= 100; j += 2) {
			mat[i][j] = '#';
			used_b++;
		}
	}

	if(swapped) {
		fori(i, 1, 100 + 1) {
			fori(j, 1, 100 + 1) {
				mat[i][j] = mat[i][j] == '.' ? '#' : '.';
			}
		}
	}

	cout << 100 << " " << 100 << '\n';
	fori(i, 1, 100 + 1) {
		fori(j, 1, 100 + 1) {
			cout << mat[i][j];
		}
		cout << '\n';
	}

	return 0;
}


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

long long X;

bool is_prime(long long X) {
    if(X < 2) return false;
    for(long long i = 2; i * i <= X; i++){
        if(X % i == 0) return false;
    }

    return true;
}

int main() {
    // cout << is_prime(23LL) << endl;
    // return 0;
    cin >> X;

    for (long long i = X; ; i++) {
        // cout << is_prime(i) << endl;
        if (is_prime(i)) {
            cout << i << endl;
            break;
        } 
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int a[106]={};
    int n,ans=0;
    cin>>n;
    for(int z=0;z<n;z++){
        cin>>a[z];
    }
    for(int z=0;z<=n;z++){
        for(int o=z+1;o<=n;o++){
            for(int p=o+1;p<=n;p++){
                //cout<<z<<" ";
                //cout<<o<<" ";
                //cout<<p<<" ";
                //cout<<endl;
                if(a[z]+a[o]>a[p]&&a[z]<a[o]+a[p]&&a[z]+a[p]>a[o]&&a[z]!=a[p]&&a[z]!=a[o]&&a[o]!=a[p]){
                    ans++;
                    //cout<<a[z]<<" ";
                    //cout<<a[o]<<" ";
                    //cout<<a[p]<<" ";
                    //cout<<endl;
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3596
def BellmanFord(s,N,Edge):
    INF=float("inf")
    dist=[INF]*N
    neg=[False]*N
    dist[s]=0
    for i in range(N-1):
        for f,t,c in Edge:
            if dist[t]>dist[f]+c and dist[f]!=INF:
                dist[t]=min(dist[t],dist[f]+c)
    for i in range(N):
        for f,t,c in Edge:
            if dist[t]>dist[f]+c and dist[f]!=INF:
                dist[t]=dist[f]+c
                neg[t]=True
            if neg[f]:
                neg[t]=True
    return dist,neg

n,m=map(int,input().split())
es=[]
for _ in range(m):
    a,b,c=map(int,input().split())
    es.append((a-1,b-1,-c))
    
res, neg =BellmanFord(0,n,es)
if not neg[-1]:
    print(-res[-1])
else:
    print("inf")

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a<b)
    swap(a,b);
  if(b<c)
    swap(b,c);
  if(a<b)
    swap(a,b);
  cout<<a-b+b-c<<endl;
}

Measured memory_bytes: 256
import Data.List
main=do
 n<-getLine
 a<-map(read::String->Int).words<$>getLine
 let ai=sort$zip a[1..]
 let as=map fst$ai
 let g=map(\a->(head a,length a))$group$as
 let ans=sum$map(\(k,v)->v*(v-1)`div`2)$g
 let x=f ans as g
 putStr$unlines$map(show.snd)$sort$map(\(a,(b,c))->(c,a))$zip x$ai
f ans[]g=[]
f ans(a:as)ag@((k,v):g)
 |a==k=ans-v+1:f ans as ag
 |otherwise=f ans(a:as)g

Measured memory_bytes: 109172
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  string S;
  cin >> S;
  ll N = S.size() + 1;
  vector<ll> num(N, 0);
  for (ll i = 0; i < N - 1; ++i) {
    if (S[i] == '<') {
      num.at(i + 1) = num.at(i) + 1;
    }
  }
  // for (ll i = 0; i < N; ++i) {
  //   cout << num.at(i) << ' ';
  // }
  // cout << endl;
  for (ll i = N - 1; i > 0; --i) {
    if (S[i - 1] == '>') {
      num.at(i - 1) = max(num.at(i) + 1, num.at(i - 1));
    }
  }
  // for (ll i = 0; i < N; ++i) {
  //   cout << num.at(i) << ' ';
  // }
  // cout << endl;
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    ans += num.at(i);
  }
  cout << ans << endl;
}


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

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    int a = 100 * r + 10 * g + b;
    if (a % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector <string> w(n,"");
    for(int i = 0; i < n; i++){
        cin >> w[i];
        if(i!=0){
            if(w[i-1].back()!=w[i][0]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    sort(w.begin(),w.end());
    for(int i = 1; i < n; i++){
        if(w[i-1].compare(w[i])==0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3580
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"

#define Pig (OO)

using namespace std;

const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

int n;
ll s[100010];
int used[100010];

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	cin>>n;
	for(int i=0;i<n;i++)cin>>s[i];
	
	ll ans=0;
	
	for(int i=1;i<=n;i++)
	{
		ll sum=0;
		
		for(int j=1;i*j<=n;j++)
		{
			int a=i*j;
			int b=n-1-a;
			
			int A=b;
			int B=b-i;
			
			if(A<=0||B<=0)break;
			if(a<0||a>=n||b<0||b>=n)break;
			if(a==b)break;
			if(used[a]==i||used[b]==i)break;
			
			used[a]=used[b]=i;
			
			sum+=s[a]+s[b];
			
			ans=max(ans,sum);
		}
	}
	
	cout<<ans;
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__);
#else
#define dbg(...) 
#endif

int main() {
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	if(s=="ARC") cout << "ABC";
	else cout << "ARC";
	cout << endl;
	return 0;
}


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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define pb push_back
#define mp make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printV(vector<T>& a, int n) { rep(i, 0, n) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	string s;
	cin>>s;
	vector<int> freq(2);
	for(int i=0; i<sz(s); i++) {
		freq[s[i]-'0']++;
	}
	int ans=min(freq[0], freq[1])*2;
	cout<<ans<<"\n";
    return 0;
}



Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class Main {
	static List<List<Hen>> list;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		list = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			list.add(new ArrayList<>());
		}
		UnionFind uf = new UnionFind(n);
		Hen[] arr = new Hen[m];
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			Hen h = new Hen();
			h.a = Integer.parseInt(sa[0]) - 1;
			h.b = Integer.parseInt(sa[1]) - 1;
			list.get(h.a).add(h);
			list.get(h.b).add(h);
			if (!uf.same(h.a, h.b)) {
				h.need = true;
				uf.union(h.a, h.b);
			}
			arr[i] = h;
		}
		br.close();

		if (m % 2 == 1) {
			System.out.println(-1);
			return;
		}

		dfs(0, -1);

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < m; i++) {
			pw.println(++arr[i].c + " " + ++arr[i].d);
		}
		pw.flush();
	}

	static void dfs(int x, int p) {
		for (Hen h : list.get(x)) {
			int ch = h.a;
			if (ch == x) {
				ch = h.b;
			}
			if (h.need && ch != p) {
				dfs(ch, x);
			}
		}

		int cnt = 0;
		List<Hen> work = new ArrayList<>();
		for (Hen h : list.get(x)) {
			if (h.d == -1) {
				work.add(h);
			} else {
				if (h.c == x) {
					cnt++;
				}
			}
		}

		for (Hen h : work) {
			int ch = h.a;
			if (ch == x) {
				ch = h.b;
			}
			h.c = x;
			h.d = ch;
		}
		if (cnt % 2 != work.size() % 2) {
			Hen h = work.get(0);
			int tmp = h.c;
			h.c = h.d;
			h.d = tmp;
		}
	}

	static class Hen {
		int a, b, c, d = -1;
		boolean need;
	}

	static class UnionFind {
		int[] parent, size;

		UnionFind(int n) {
			parent = new int[n];
			size = new int[n];
			for (int i = 0; i < n; i++) {
				parent[i] = i;
				size[i] = 1;
			}
		}

		void union(int x, int y) {
			int px = find(x);
			int py = find(y);
			if (px != py) {
				parent[px] = py;
				size[py] += size[px];
			}
		}

		int find(int x) {
			if (parent[x] == x) {
				return x;
			}
			parent[x] = find(parent[x]);
			return parent[x];
		}

		boolean same(int x, int y) {
			return find(x) == find(y);
		}
	}
}


Measured memory_bytes: 86784
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String first = s.substring(0, 1);
		String end = s.substring(3);

		String regex1 = "^%s{3}[0-9]$";
		regex1 = String.format(regex1, first);
		String regex2 = "^[0-9]%s{3}$";
		regex2 = String.format(regex2, end);

		if (s.matches(regex1) || s.matches(regex2)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}
}

Measured memory_bytes: 21716
N,M = map(int,input().split())
num = 0
if N>M:
    num+=N
    N-=1
    if N>M:
        print(num+N)
    else:
        print(num+M)
else:
    num+=M
    M-=1
    if M>N:
        print(num+M)
    else:
        print(num+N)

Measured memory_bytes: 3060
#include <stdio.h>
int main(int argc, const char * argv[]) {
    int x,y[1000];
    scanf("%d",&x);
        for(int z=1;z<=x;z++){
            scanf("%d",&y[z]);
        }
        for(int z=x;z>0;z--){
            printf("%d",y[z]);
            if(z!=1){
                printf(" ");
            }
            if(z==1){
                printf("\n");

            }

        }


    return 0;
}



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

#define N 1000
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define fastio ios::sync_with_stdio(false); cin.tie(0)

int main(){
    fastio;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.in", "r", stdin);
    //     freopen("output.out", "w", stdout);
    // #endif
    int n, m, k, s, p[10];
    int cnt, ans = 0;
    bool can;
    vector<int> v[10];
 	cin >> n >> m;
 	for(int i = 0 ; i < m ; i++){
 		cin >> k;
 		for(int j = 0 ; j < k ; j++){
 			cin >> s;
 			v[i].pb(s);
 		}
 	}   
 	
 	for(int i = 0 ; i < m ; i++)
 		cin >> p[i];


 	for(int i = 0 ; i < pow(2, n) ; i++){
 		can = true;
 		for(int j = 0 ; j < m ; j++){
 			cnt = 0;
 			for(auto l : v[j]){
 				if((i >> (l - 1))%2)
 					cnt++;
 			}
 			if((cnt%2) != p[j]){
 				can = false;
 				break;
 			}
 		}
 		if(can) ans++;
 	}
 	cout << ans << endl;

    return 0;
}

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

// main.cpp

int main() {
  std::int_fast64_t n;
  std::cin >> n;
  std::unordered_set<std::int_fast64_t> d;
  std::copy_n(std::istream_iterator<std::int_fast64_t>(std::cin), n, std::inserter(d, d.end()));
  std::cout << d.size() << std::endl;
  return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int64)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

template<typename T,T MOD,T B>
struct RollingHash{
  using ll = long long;
  vector<T> hash,po;
  RollingHash(){}
  RollingHash(vector<T> vs){init(vs);}
  RollingHash(string &s){
    vector<T> vs;
    for(char c:s) vs.emplace_back(c);
    init(vs);
  }
  void init(vector<T> vs){
    int n=vs.size();
    hash.assign(n+1,0);
    po.assign(n+1,1);
    for(int i=0;i<n;i++){
      hash[i+1]=((ll)hash[i]*B+vs[i])%MOD;
      po[i+1]=(ll)po[i]*B%MOD;
    }
  }
  //S[l, r)
  T find(int l,int r){
    T res=(ll)hash[r]+MOD-(ll)hash[l]*po[r-l]%MOD;
    return res>=MOD?res-MOD:res;
  }
};

int main(void) {
  int64 N;
  cin >> N;
  vector<int64> a(N);
  REP(i, N) cin >> a[i];
  int64 cnt = 1, res = 0;
  REP(i, N) {
    if (a[i] == cnt) {
      cnt++;
    } else {
      res++;
    }
  }
  cout << (res == N ? -1 : res) << endl;
}


Measured memory_bytes: 1792
from collections import defaultdict
class UnionFind:
    def __init__(self, num):
        self.table = [-1 for _ in range(num)]
        self.sz = defaultdict(lambda:1)

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)

        if s1 != s2:
            size = self.sz[s1]+self.sz[s2]
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            s = self.find(x)
            self.sz[s] = size
            return True
        return False

    def size(self, x):
        s = self.find(x)
        return self.sz[s]

N,M = map(int,input().split())
u = UnionFind(N)
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    u.union(a,b)

ans = 0
for i in range(N):
    ans = max(ans,u.size(i))

print(ans)

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===


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

	int N, M, Q;
	cin >> N >> M >> Q;

	vector<Vi> ans(N + 1, Vi(N + 1));
	for (int i = 0; i < M; ++i) {
		int L, R;
		cin >> L >> R;
		--L; --R;
		++ans[0][R];
		--ans[L + 1][R];
		--ans[0][N];
		++ans[L + 1][N];
	}
	for (int i = 0; i < N; ++i) {
		for (int j = i; j < N; ++j) {
			ans[i + 1][j] += ans[i][j];
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = i; j < N; ++j) {
			ans[i][j + 1] += ans[i][j];
		}
	}

	for (int i = 0; i < Q; ++i) {
		int L, R;
		cin >> L >> R;
		--L; --R;
		cout << ans[L][R] << "\n";
	}

	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

    vector<ll> A(N);
    for(ll i = 0; i < N; i++){
        cin >> A[i];
    }

    sort(A.begin(),A.end());

    ll cnt = 0;

    for(ll i=1; i<N; i++){
        if(A[i-1] == A[i]){
            cnt += 1;
        }
    }

    if(cnt%2==0){
        cout << N - cnt << endl;
    }
    else{
        cout << N - cnt - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 4028
#include <iostream>
#include <cmath>
#define PI 3.14159265359
#include<cstdio>
#include<iomanip>
using namespace std;
int main(){
  cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
	double a, b, x;
	cin >> a >> b >> x;
  	double c,d,e;
    c  = 2*b - 2*x/(a*a);
  	d = 180*atan2(c,a)/PI;
    e = 2*x/(a*b); 
  if(a*a*b/2 < x){
 cout<<d<<endl; 
  }
  else{
  cout<<90-(180*atan2(e,b))/PI<<endl;
}
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a = input()

    if a == a.upper():
        print("A")
    else:
        print("a")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61684
#include<iostream>
#include<algorithm>
using namespace std;
int gcd(int,int);
int lcm(int,int);
int tes(int,int);

int main(){
  int a,b;
  while(cin >> a >> b){
    cout << gcd(a,b);
    cout << " " << lcm(a,b) << endl;
  }
}

int gcd(int a,int b){
  int n;
  while(a!=b)
    {
      if(a>b)a=a-b;
      else{b=b-a;}
    }
  return a;
}
/*
int tes(int a,int b){
  if(b == 0)return a;
  return tes(b,a%b);
}
*/

int lcm( int a,int b){
  return (a/gcd(a,b))*b;
}

Measured memory_bytes: 0
N = int(input())
D, X = map(int, input().split())
A = [int(input()) for i in range(N)]
count = 0
def HowManyDaysEaten(d, a):
    l = list()
    i = 1
    while d >= (i - 1) * a + 1:
        l.append((i - 1) * a + 1)
        i += 1
    return l 
for i in A:
    count += len(HowManyDaysEaten(D, i))
print(count + X)

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int ck(ll a, ll b)
{
    int t_a = 0, t_b = 0;
    while (a)
    {
        t_a++;
        a /= 10;
    }
    while (b)
    {
        t_b++;
        b /= 10;
    }

    return (t_a <= t_b) ? t_b : t_a;
}

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

    int ans = 1001001001;
    for (ll a = 1; a * a <= n; a++)
    {
        if (n % a != 0)
        {
            continue;
        }
        ll b = n / a;
        ans = min(ans, ck(a, b));
    }

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

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define PI acos(-1.0)
#define mod 1e9+7
using namespace std;
ll dp[405][405];
ll arr[405], sum[405];
ll DP(int st, int end)
{
    if(st==end) return 0;
    if(dp[st][end]) return dp[st][end];
    int mid=(st+end)/2;
    ll ans=100000000000000;
    for(int mid=st; mid<end; mid++)
    {
        ans=min(ans, DP(st, mid)+DP(mid+1, end)+(sum[mid]-sum[st-1])+(sum[end]-sum[mid]));
    }
    return dp[st][end]=ans;
}
int main()
{
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        scanf("%lld", &arr[i]);
        sum[i]=sum[i-1]+arr[i];
    }
    ll ans=DP(1, n);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define endl '\n'
#define PI 3.14159265
#define ff first
#define ss second
#define tab '\t'
#define deb cout<<"error"<<endl
#define uset unordered_set
#define mset multiset
#define umap unordered_map
#define mmap multimap
#define len length

 
signed main()
{
    int x;
    cin>>x;
	int i;
	for(i=x;;i+=x)
	{
		if(i%360==0)
		{
		
		cout<<i/x<<endl;
		return 0;
	}
	}
}

Measured memory_bytes: 3592
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = Integer.parseInt(br.readLine());
		String[] ss0 = br.readLine().trim().split(" ", 0);
		Integer[] ii0 = new Integer[N];
		for(int i = 0; i < N; i++){
			ii0[i] = Integer.parseInt(ss0[i]);
		}
		
		//配列のソート
		Arrays.sort(ii0);
		
		System.out.println(ii0[N-1]-ii0[0]);
		



	return;
	}



}


Measured memory_bytes: 21076
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n):
    for j in range(i+1, n):
        d = sum((y-z)**2 for y, z  in zip(x[i], x[j])) ** 0.5
        if int(d) == d:
            ans += 1
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
int TaroHappiness[100005][3] = {0};
int n;
void read()
{
    cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < 3; j++)
        {
            int x;
            cin >> x;
            TaroHappiness[i][j] = x;
        }
}
void solve(int n)
{
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            if(j == 2)
            {
                if( TaroHappiness[i - 1][j - 1] < TaroHappiness[i - 1][j - 2])
                    TaroHappiness[i][j] = TaroHappiness[i][j] + TaroHappiness[i - 1][j - 2];
                else
                    TaroHappiness[i][j] = TaroHappiness[i][j] + TaroHappiness[i - 1][j-1];

            }
            if(j == 0)
            {
                if(TaroHappiness[i-1][j+1] <  TaroHappiness[i-1][j+2])
                    TaroHappiness[i][j] = TaroHappiness[i][j] + TaroHappiness[i-1][j+2];
                else
                    TaroHappiness[i][j] = TaroHappiness[i][j] + TaroHappiness[i - 1][j + 1];
            }
            if(j == 1)
            {
                if(TaroHappiness[i-1][j-1] <  TaroHappiness[i-1][j+1])
                    TaroHappiness[i][j] = TaroHappiness[i][j] + TaroHappiness[i-1][j+1];
                else
                    TaroHappiness[i][j] = TaroHappiness[i][j] + TaroHappiness[i - 1][j - 1];
            }
        }
    }
}
int main()
{
    read();
    solve(n);
    int maxi1 = 0;
    int maxi2 = 0;
    if(TaroHappiness[n -1][1] > TaroHappiness[n - 1][2])
        maxi1 = TaroHappiness[n-1][1];
    else maxi1 = TaroHappiness[n-1][2];
    if(TaroHappiness[n-1][0] > maxi1)
        maxi2 = TaroHappiness[n-1][0];
    else maxi2 = maxi1;
    cout << maxi2;



}

Measured memory_bytes: 1408
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n, a, b, k, total int
	var s string

	fmt.Scan(&n)
	fmt.Scan(&a)
	fmt.Scan(&b)

	total = 0

	for i := 1; i < n+1; i++ {
		sum := 0
		s = fmt.Sprint(i)
		for i := 0; i < len(s); i++ {
			k, _ = strconv.Atoi(s[i:i+1])
			sum += k
		}
		if a <= sum && sum <= b {
			total += i
		}

	}
	fmt.Println(total)
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define ALL(v) (v).begin(),(v).end()
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
struct UnionFind {
	vector<int> par;
	vector<int> size;

	UnionFind(int n) {
		par = vector<int>(n);
		for (int i = 0; i < n; i++) par[i] = i;
		size = vector<int>(n, 1);
	}

	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (size[x] < size[y]) {
			par[x] = y;
			size[y] += size[x];
		}
		else {
			par[y] = x;
			size[x] += size[y];
		}
	}
};
map<P, int> idx;
ll x[50], y[50];
int main() {
	int N;
	cin >> N;
	if (N == 1) {
		cout << 1 << endl;
		return 0;
	}
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
		idx[P(x[i], y[i])] = i;
	}
	set<P> S;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i == j) continue;
			S.insert(P(x[i] - x[j], y[i] - y[j]));
		}
	}
	int ans = 1 << 30;
	for (P p : S) {
		UnionFind U(N);
		for (int i = 0; i < N; i++) {
			ll nx = x[i] - p.first, ny = y[i] - p.second;
			if (idx.count(P(nx, ny)) > 0) {
				U.unite(i, idx[P(nx, ny)]);
			}
		}
		set<int> g;
		for (int i = 0; i < N; i++) g.insert(U.find(i));
		ans = min(ans, (int)g.size());
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

const int MAX = 10005;

bool visited[MAX];
int N, indeg[MAX];
vector<int> G[MAX];
list<int> out;


void bfs(int s){
    queue<int> q;
    q.push(s);
    visited[s] = true;

    while(!q.empty()){
        int u = q.front(); q.pop();
        out.push_back(u);
        for(int i=0; i<G[u].size(); i++){
            int v = G[u][i];
            indeg[v]--;
            if(indeg[v] == 0 && visited[v] == false){
                visited[v] = true;
                q.push(v);
            }
        }
    }
}

void tsort(){
    for(int i=0; i<N; i++) indeg[i] = 0;

    for(int u=0; u<N; u++){
        for(int i=0; i<G[u].size(); i++){
            indeg[G[u][i]]++;
        }
    }

    for(int u=0; u<N; u++){
        if(indeg[u] == 0 && !visited[u]) bfs(u);
    }

    for(auto itr = out.begin(); itr != out.end(); itr++){
        cout << *itr << endl;
    }

}

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

    for(int i=0; i<N; i++) visited[i] = false;

    for(int i=0; i<M; i++){
        int s, t; cin >> s >> t;
        G[s].push_back(t);
    }

    tsort();
}


Measured memory_bytes: 4088
import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        int cnt = 0;
        for (int i = A; i <= B; i++) {
            char[] s = new StringBuilder().append(i).toString().toCharArray();
            boolean ok = true;
            for (int j = 0; j < 5 / 2 ; j++) {
                if (s[j] != s[4 - j]) {
                    ok = false;
                    break;
                }
            }
            if (ok) cnt++;
        }

        System.out.println(cnt);

        return;
    }

}

Measured memory_bytes: 40148
n, a, b = map(int, input().split())

total = 0

for i in range(1, n + 1):

    p = i // 10000 + (i % 10000) // 1000 + (i % 1000) // 100 + (i % 100) // 10 + (i % 10)

    if a <= p <= b:
        total += i

print(total)


Measured memory_bytes: 2940