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

#ifdef _DEBUG
#define debug(x) cout << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#define INFILE freopen("input.txt", "r", stdin)
#else
#define debug(x)
#define INFILE
#endif

#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL9_MOD = 1000000009LL;
static constexpr ll LL7_MOD = 1000000007LL;
static constexpr ll INF = 1LL << 60;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

ll memo[100010];

ll longest_path(ll vertex, const vector<vector<int>>& adj_list) {
  if (memo[vertex] != -1) return memo[vertex];

  ll max_path = 0;
  for (ll next_vertex : adj_list[vertex]) {
    chmax(max_path, longest_path(next_vertex, adj_list) + 1);
  }

  return memo[vertex] = max_path;
}

int main(int argc, char* argv[]) {
  INFILE;

  ll n, m;
  cin >> n >> m;

  vector<vector<int>> v(n, vector<int>(0));
  Fill(memo, ll(-1));

  REP(i, 0, m) {
    int from, to;
    cin >> from >> to;
    from--, to--;  // 0-indexed
    v[from].push_back(to);
  }

  ll result = 0;
  REP(i, 0, n) { chmax(result, longest_path(i, v)); }

  cout << result << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

template <class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin>>x;
  int y;
  y=x/100;
  if(x>100*y+10*y+y){
    cout<<100*(y+1)+10*(y+1)+y+1<<endl;
  }
  else{
    cout<<100*y+10*y+y<<endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String S = sc.next();
    String T = sc.next();
    
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    String U = sc.next();
    
    int aOut = A;
    int bOut = B;
    if (S.equals(U)) {
      aOut -= 1;
    } else {
      bOut -= 1;
    }
    
    System.out.println(aOut + " " + bOut);
  }
}

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

object Main {

  def main(args: Array[String]) = {
    val n = readInt
    val l = readLine.split(" ").map(_.toInt)
    printf("%d %d %d\n",l.min,l.max,l.foldLeft(0.toLong)(_+_))
  }
}

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

void solve(long long N, long long K, std::vector<long long> A)
{
    vector<ll> towns(N+1);
    ll town = 1;
    towns[1] = K;
    while (K--) {
        town = A[town];
        if (towns[town] != 0) {
            K %= towns[town] - K;
        }
        towns[town] = K;
    }
    cout << town << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> A(N+1);
    for (int i = 1; i <= N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 6420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Stack<Integer> S = new Stack<Integer>();
		int A,B;

		try {

			String input[] = br.readLine().split("\\s+");

			for(int i = 0; i < input.length; i++){
				if(checkInt(input[i])){
					S.push(Integer.parseInt(input[i]));
					continue;
				}

				B = S.peek();
				S.pop();
				A = S.peek();
				S.pop();

				if(input[i].equals("+")){
					S.push(A+B);
				}else if(input[i].equals("*")){
					S.push(A*B);
				}else if(input[i].equals("-")){
					S.push(A-B);
				}
			}
			System.out.println(S.peek());

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static boolean checkInt(String number){
		Pattern p = Pattern.compile("^[0-9]+$");
		Matcher m = p.matcher(number);
		return m.matches();
	}

}



Measured memory_bytes: 24880
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>

using u4t = std::uint32_t;
using i4t = std::int32_t;
using u8t = std::uint64_t;
using i8t = std::int64_t;

int main() {
  int A,B,C;
  std::cin >> A>>B>>C;
  int count = 0;
  for(;;){
    if (A&1|B&1|C&1) break;
    if (A==B&&B==C){count=-1;break;}
    int newA = (B+C)/2;
    int newB = (C+A)/2;
    int newC = (A+B)/2;
    A=newA;
    B=newB;
    C=newC;
    count++;
  }
  std::cout<<count<<std::endl;
  return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (A, B) = readLine()!!.split(" ").map { it.toLong() }
    println((A * B) / gcd(A, B))
}

tailrec fun gcd(a: Long, b: Long): Long =
    if (b == 0L) a else gcd(b, a % b)

Measured memory_bytes: 37868
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Rummy
 */
public class Main {


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

		int T = parseInt(br.readLine());

		for (int i = 0; i < T; i++) {

			StringTokenizer st1 = new StringTokenizer(br.readLine());
			StringTokenizer st2 = new StringTokenizer(br.readLine());

			int[] R = new int[10];
			int[] G = new int[10];
			int[] B = new int[10];

			for (int j = 0; j < 9; j++) {
				int n = parseInt(st1.nextToken());
				switch (st2.nextToken().charAt(0)) {
					case 'R':
						R[n]++;
						break;
					case 'G':
						G[n]++;
						break;
					case 'B':
						B[n]++;
						break;
				}
			}

			//
			int count = solve(R, 1, 0) + solve(G, 1, 0) + solve(B, 1, 0);
			System.out.println(count >= 3 ? 1 : 0);
		}
	}

	public static int solve(int[] cards, int s, int c) {

		if (s == 10) return c;

		int c1 = 0, c2 = 0, c3 = 0;

		if (cards[s] >= 3) {
			int[] _cards = cards.clone();
			_cards[s] -= 3;
			c1 = solve(_cards, s + 1, c + 1);
		}

		if (s <= 7 && cards[s] >= 1 && cards[s + 1] >= 1 && cards[s + 2] >= 1) {
			int[] _cards = cards.clone();
			_cards[s]--;
			_cards[s + 1]--;
			_cards[s + 2]--;
			// ???????????????????????°???????????¨???????????????????????????????????????????????????????????§????????????
			if (_cards[s] >= 1) {
				c2 = solve(_cards, s, c + 1);
			} else {
				c2 = solve(_cards, s + 1, c + 1);
			}
		}

		c3 = solve(cards, s + 1, c);

		return Math.max(c1, Math.max(c2, c3));
	}
}

Measured memory_bytes: 25084
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
#include<type_traits>
using namespace std;
char D[28][28];
int Y ;
void serch(int X, int Q) {
	if (D[X][Q] == '.'||D[X][Q]=='@') {
		Y++;
		D[X][Q] = '#';
		serch(X - 1, Q);
		serch(X + 1, Q);
		serch(X , Q-1);
		serch(X , Q+1);
		

	}
	else return;
}


int main() {
	int H, W;
	cin >> W >> H;
	for (int i = 0; i <28; i++) {
		for (int j = 0; j <28; j++) {
			D[i][j] = '#';
		}
	}
	int Sx,Sy;
	while (H) {
		 Y = 0;
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				cin >> D[j][i];
				if (D[j][i] == '@') {
					Sx = j;
					Sy = i;
				}
			}
		}
		serch(Sx, Sy);
		
		cout << Y << endl;
		for (int i = 0; i <28; i++) {
			for (int j = 0; j <28; j++) {
				D[i][j] = '#';
			}
		}
		cin >> W >> H;
	}
	return 0;
}



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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<char>> board(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> board[i][j];
        }
    }
    for (int i = 0; i < h; i++) {
        bool comp = true;
        for (int j = 0; j < w; j++) {
            if (board[i][j] == '#') {
                comp = false;
                break;
            }
        }
        if (comp) {
            for (int j = 0; j < w; j++) {
                board[i][j] = ' ';
            }
        }
    }
    for (int j = 0; j < w; j++) {
        bool comp = true;
        for (int i = 0; i < h; i++) {
            if (board[i][j] == '#') {
                comp = false;
                break;
            }
        }
        if (comp) {
            for (int i = 0; i < h; i++) {
                board[i][j] = ' ';
            }
        }
    }
    for (int i = 0; i < h; i++) {
        bool newline = false;
        for (int j = 0; j < w; j++) {
            if (board[i][j] != ' ') {
                cout << board[i][j];
                newline = true;
            }
        }
        if (newline) {
            cout << endl;
        }
    }

    return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

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

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  int q;
  cin >> q;;
  list<int> a;
  auto itr = a.end();

  vector<int> ans;
  rep(i,q) {
    int command;
    cin >> command;
    if (command == 0) {
      int x; cin >> x;
      itr = a.insert(itr,x);
    } else if (command == 1) {
      int d; cin >> d;
      itr = next(itr,d);
    } else {
      itr = a.erase(itr);
    }
  }
  for (auto i : a) cout << i << endl;

  return 0;
}



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

using namespace std;
const int mod = 1000000007;

int main()
{
    int n ;
    
    cin>>n;
   vector< long long>dp(2001);
   dp[0]=1;
   for(int i =0;i<=2000;i++)
   for(int j =0;j<=i-3;j++)
   {
       dp[i]+=dp[j];
       dp[i]=dp[i]%mod;
   }
cout<<dp[n];
    return 0;
}


Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    private const int INF = 1000000000;
    public static void Main()
    {
        int[] box = SpRead(' ').Select(int.Parse).ToArray();
        int N = box[0], K = box[1];
        string[] imp = SpRead(' ');
        for (int i = N; i <= 100000; i++)
        {
            bool flag = false;
            foreach (var p in imp) if (i.ToString().Contains(p)) flag = true;
            if (flag || i < N) continue;

            Console.WriteLine(i);
            break;
        }
    }
}

public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static long[] LSRead()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
}


Measured memory_bytes: 17472
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <queue>
#define ll long long
using namespace std;
 
int main() {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  cout << 60*h2+m2-60*h1-m1-k;
}


Measured memory_bytes: 3624
import math
n=int(input())
a=[]
for _ in range(n):
    a.append(list(map(int,input().split())))
s=0
for i in range(n):
    for j in range(n):
        if j!=i:
            s+=((a[i][0]-a[j][0])**2+(a[i][1]-a[j][1])**2)**0.5
print((n-1)*s/(n*(n-1)))

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

using namespace std;

int a[100005] , n;

int main()
{
    int cmmdc;
    cin >> n;
    for(int i = 1 ; i <= n ; i++)
        cin >> a[i];
    cmmdc = a[1];
    for(int i = 2 ; i <= n ; i++)
    {
        int r;
        while(a[i])
        {
            r = cmmdc % a[i];
            cmmdc = a[i];
            a[i] = r;
        }
        ///cout << cmmdc << "\n";
    }
    cout << cmmdc << "\n";
    return 0;
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N - 1);
    REP(i, N) {
        cin >> A[i];
        --A[i];
    }
    REP(i, N) cin >> B[i];
    REP(i, N - 1) cin >> C[i];
    int result = accumulate(all(B), 0);
    REP(i, N - 1) {
        if (A[i] + 1 == A[i + 1]) {
            result += C[A[i]];
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define MAXN 200010

struct edge{
	int to,next;
	edge(int _to=0,int _next=0):to(_to),next(_next){}
}e[MAXN];

int n,root;
int g[MAXN],nume;
int p[MAXN];
bool visit[MAXN];
int f[MAXN];
bool cnt[MAXN];

void addEdge(int u,int v){
	e[nume]=edge(v,g[u]);
	g[u]=nume++;
}

void dfs(int x){
	for(int i=g[x];~i;i=e[i].next)
		if(e[i].to!=root) 
			dfs(e[i].to);
	for(int i=g[x];~i;i=e[i].next) 
		if(f[e[i].to]>=0) 
			cnt[f[e[i].to]]=1;
	for(f[x]=0;cnt[f[x]];f[x]++);
	for(int i=g[x];~i;i=e[i].next) 
		if(f[e[i].to]>=0) 
			cnt[f[e[i].to]]=0;
}

bool check(){
	int x=p[root];
	for(int i=g[x];~i;i=e[i].next)
		cnt[f[e[i].to]]=1;
	bool flag=1;
	if(cnt[f[x]]) flag=0;
	for(int i=0;i<f[x];i++) if(!cnt[i]) flag=0;
	memset(cnt,0,sizeof cnt);
	return flag;
}

bool gao(){
	int x=1;
	while(!visit[x]) visit[x]=1,x=p[x];
	memset(visit,0,sizeof visit);
	memset(f,-1,sizeof f);
	root=x;
	dfs(root);
	if(check()) return 1;
	int f0=f[p[x]];
	memset(f,-1,sizeof f);
	f[root]=f0;
	dfs(root);
	if(check()) return 1;
	return 0;
}

int main(){
	memset(g,-1,sizeof g);
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",p+i),addEdge(p[i],i);
	if(gao()) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
}

Measured memory_bytes: 9600
a, b = gets.split

if -1000 <= a.to_i && a.to_i <= 1000 && -1000 <= b.to_i && b.to_i <= 1000 then  

if a.to_i > b.to_i then
    puts "a > b"
elsif a.to_i < b.to_i then
    puts "a < b"
else
     puts "a == b"
end

end

Measured memory_bytes: 8572
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    void solve() throws IOException {
        int n = ni();
        long a = ni();
        long b = ni();
        long[] x = nla(n);
        long ans = 0;
        for (int i = 0; i < n - 1; i++) {
            if ((x[i + 1] - x[i]) * a < b) {
                ans += (x[i + 1] - x[i]) * a;
            } else {
                ans += b;
            }
        }

        out.println(ans);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 24320
//a.c A-B+/-A
#include<stdio.h>

int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(b%a==0){
        printf("%d\n",a+b);
    }else{
        printf("%d\n",b-a);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

#define N 1000000
#define all(p) p.begin(),p.end()
bool primes[N];

int main() {
    vector<int> prime;
    
    primes[0] = primes[1] = 1;

    for (int i=2;i<N;i++) {
        if(!primes[i]) {
            for (int j=i;j<N;j+=i) primes[j] = 1;
            prime.push_back(i);
        }
        if(prime.size() == 100100) break; 
    }
    int n,p;
    while(cin >> n >> p && !(n==-1&&p==-1) ) {
        int i;
        vector<int> mp;
        for (i=0;prime[i]<=n;i++);
        for (int j=i;j<i+25;j++)  for(int k=j;k<i+25;k++) 
                mp.push_back(prime[j]+prime[k]);
        sort(all(mp));
        cout << mp[p-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 2324
// sum of bitwise OR of all pairs 
#include <bits/stdc++.h> 
using namespace std; 
 #define mod 1000000007
// Returns sum of bitwise OR 
// of all pairs
long long power(long long x, long long y, long long p) 
{ 
    long long res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
}  
long long int sumXOR(long long int arr[], long long n) 
{ 
    long long int sum = 0; 
    for (long long i = 0; i < 128; i++)  
    { 
        //  Count of zeros and ones 
        long long zc = 0, oc = 0;  
          
        // Individual sum at each bit position 
        long long int idsum = 0;  
        for (long long j = 0; j < n; j++) 
        { 
            if (arr[j] % 2 == 0) 
                zc++; 
            else
                oc++; 
            arr[j] /= 2; 
        } 
          
        // calculating individual bit sum  
        idsum = (oc%mod * zc%mod * (power(2,i,mod))%mod)%mod;  
  
        // final sum     
        sum =(sum%mod+idsum%mod)%mod;  
    } 
    return sum; 
} 
  
int main() 
{ 
    long long int sum = 0,n;
    cin>>n;
    long long a[n],i;
    for(i=0;i<n;i++)
    cin>>a[i]; 
    sum = sumXOR(a, n); 
    cout << sum%mod; 
    return 0; 
} 

Measured memory_bytes: 2560
N, Y = map(int,input().split())

for i in range(N+1):
    for j in range(N+1-i):
        if Y == 10000*i + 5000*j + (N - i - j)*1000:
            z = N - i - j
            print(str(i)+" "+str(j)+" "+str(z))
            exit()
print("-1 -1 -1")

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type operation struct {
	b int
	c int
}

type ope []operation

func (o ope) Len() int {
	return len(o)
}

func (o ope) Swap(i, j int) {
	o[i], o[j] = o[j], o[i]
}

func (o ope) Less(i, j int) bool {
	return o[i].c < o[j].c
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, m := nextInt(), nextInt()

	aArray := make([]int, n)
	for i := 0; i < n; i++ {
		aArray[i] = nextInt()
	}

	var o ope = make([]operation, m)
	for j := 0; j < m; j++ {
		o[j].b, o[j].c = nextInt(), nextInt()
	}
	sort.Sort(sort.Reverse(o))

	cnt := 0
	for j := 0; j < m && cnt < n; j++ {
		for k := 0; k < o[j].b && cnt < n; k++ {
			aArray = append(aArray, o[j].c)
			cnt++
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(aArray)))

	ans := 0
	for i := 0; i < n; i++ {
		ans += aArray[i]
	}

	fmt.Println(ans)
}


Measured memory_bytes: 10752
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;
bool comp(pair<string,ll>a,pair<string,ll>b){
  if(a.first==b.first) return a.second>b.second;
  return a.first<b.first;
}
int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);

  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<a*b-c*b-d*(a-c);
}

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

using namespace std;

inline void quit(){ exit(0); }

typedef long long ll;

ll mpow(ll _x, ll _y, ll _mod){
    if(_y==0) return 1;
    if(_y==1) return _x%_mod;
    if(_y&1) return (mpow(_x, _y-1, _mod)*_x)%_mod;
    ll _tmp = mpow(_x, _y>>1, _mod);
    return (_tmp*_tmp)%_mod;
}

int n, m, a, b;
bool ans[1002][1002];

int main(){
    cin>>n>>m>>a>>b;
    for(int i=1; i<=b; i++){
        for(int j=a+1; j<=m; j++){
            ans[i][j] = 1;
        }
    }
    for(int i=b+1; i<=n; i++){
        for(int j=1; j<=a; j++){
            ans[i][j] = 1;
        }
    }

    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            printf("%d", ans[i][j]);
        }
        puts("");
    }
}


Measured memory_bytes: 2176
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;
int n, ans, pr[N];
struct st{int w, x, y;} a[N], b[N], c[N*2];
bool cmp(st p, st q) {return p.w<q.w;}
int f(int p) {return pr[p]==p ? p : pr[p]=f(pr[p]);}

int main() {
	int i, x, y;
	scanf("%d", &n);
	for(i=1; i<=n; i++) {
		scanf("%d%d", &a[i].w, &b[i].w);
		a[i].x = b[i].x = pr[i] = i;
	}
	sort(a+1, a+n+1, cmp);
	sort(b+1, b+n+1, cmp);
	for(i=1; i<n; i++) {
		c[i] = {a[i+1].w-a[i].w, a[i].x, a[i+1].x};
		c[i+n-1] = {b[i+1].w-b[i].w, b[i].x, b[i+1].x};
	}
	sort(c+1, c+2*n-1, cmp);
	for(i=1; i<2*n-1; i++) {
		x = f(c[i].x), y = f(c[i].y);
		if(x!=y) ans += c[i].w, pr[y] = x;
	}
	printf("%d", ans);
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(),a.end());
    double x = double(a.at(0));
    for(int i=1;i<n;i++){
        x = ((double)a.at(i) + x) / 2.0;
    }
    cout << fixed << setprecision(10) << x << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;

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

// 入力
int N;
long long a[100010][3];
int f;

// DP テーブル
long long dp[100010][6];

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i][0] >> a[i][1] >> a[i][2];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i){
        for (int j = 0; j < 6; ++j) dp[i][j] = 0;
    }


    // ループ
    for (int i = 1; i < N+1; ++i) {
      chmax(dp[i][0],dp[i-1][1] + a[i-1][0]);
      chmax(dp[i][0],dp[i-1][2] + a[i-1][0]);
      chmax(dp[i][1],dp[i-1][0] + a[i-1][1]);
      chmax(dp[i][1],dp[i-1][2] + a[i-1][1]);
      chmax(dp[i][2],dp[i-1][0] + a[i-1][2]);
      chmax(dp[i][2],dp[i-1][1] + a[i-1][2]);

    }

    // 答え
    cout << max({dp[N][0],dp[N][1],dp[N][2]}) << endl;

}

Measured memory_bytes: 7296
#include <stdio.h>
long long p = 1000000007;
long long rui(long long x, long long y) {
	if (y == 0)return 1;
	if (y == 1)return x;
	if (y == 2)return x * x % p;
	if (y % 2)return rui(rui(x, y / 2), 2) * x % p;
	else return rui(rui(x, y / 2), 2);
}
long long inv(long long x) {
	return rui(x, p - 2);
}
long long n, a, b, c;
long long ans;
long long d, e;
int main() {
	scanf("%lld%lld%lld%lld", &n, &a, &b, &c);
	d = a * inv(a + b) % p;
	e = rui(d, n) * n % p;
	for (long long i = 0; i < n; i++) {
		ans += e;
		ans %= p;
		e *= (n + i + 1); e %= p;
		e *= inv(i + 1); e %= p;
		e *= b; e %= p;
		e *= inv(a + b); e %= p;
	}
	d = b * inv(a + b) % p;
	e = rui(d, n) * n % p;
	for (long long i = 0; i < n; i++) {
		ans += e;
		ans %= p;
		e *= (n + i + 1); e %= p;
		e *= inv(i + 1); e %= p;
		e *= a; e %= p;
		e *= inv(a + b); e %= p;
	}
	if (c == 0) {
		printf("%lld\n", ans);
		return 0;
	}
	printf("%lld\n", ans * 100 % p * inv(100 - c) % p);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    string s;
    cin >> s;
    s[3] = '8';
    cout << s;
    return 0;
}

Measured memory_bytes: 256
#S,T,D = map(int,input().split())
#S,T = input().split()
S = input()
if S=='SUN':
  print(7)
if S=='MON':
  print(6)
if S=='TUE':
  print(5)
if S=='WED':
  print(4)
if S=='THU':
  print(3)
if S=='FRI':
  print(2)
if S=='SAT':
  print(1)

Measured memory_bytes: 3060
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    for(int i = 0;i<n;i++){
      a[i] = sc.nextInt();
    }
    int ans = 0,times = 0,now = 1;
    for(int i = 0;i<n;i++){
      times++;
      now--;
      now = a[now];
      if(now == 2){
        ans = 1;
        break;
      }
    }
    if(ans == 1){
      System.out.println(times);
    }else{
      System.out.println(-1);
    }
  }
}


Measured memory_bytes: 50352
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] a = new Integer[n];
        Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
        sc.close();

        // 主処理
        // 値の出現回数をカウント
        Integer[] oddIndexCount = new Integer[100001];
        Arrays.fill(oddIndexCount, 0);
        for (int i = 0; i < n; i += 2) {
            oddIndexCount[a[i]]++;
        }
        Integer[] evenIndexCount = new Integer[100001];
        Arrays.fill(evenIndexCount, 0);
        for (int i = 1; i < n; i += 2) {
            evenIndexCount[a[i]]++;
        }

        // 最大と2番目の出現回数を記録
        PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
        pq.addAll(Arrays.asList(oddIndexCount));
        int oddIndexCountFirst = pq.poll();
        int oddIndexCountSecond = pq.poll();
        pq = new PriorityQueue<>(Collections.reverseOrder());
        pq.addAll(Arrays.asList(evenIndexCount));
        int evenIndexCountFirst = pq.poll();
        int evenIndexCountSecond = pq.poll();

        // 最大個数の値を取得
        int oddIndexNumber = 0;
        for (int i = 1; i < oddIndexCount.length; i++) {
            if (oddIndexCount[i] == oddIndexCountFirst) {
                oddIndexNumber = i;
                break;
            }
        }
        int evenIndexNumber = 0;
        for (int i = evenIndexCount.length - 1; 1 <= i; i--) {
            if (evenIndexCount[i] == evenIndexCountFirst) {
                evenIndexNumber = i;
                break;
            }
        }

        int result = n;
        if (oddIndexNumber == evenIndexNumber) {
            result -= Math.max(oddIndexCountFirst + evenIndexCountSecond, oddIndexCountSecond + evenIndexCountFirst);
        } else {
            result -= (oddIndexCountFirst + evenIndexCountFirst);
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 61928
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9 + 7;
const int M = 2e6 + 5;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   if(pow < 0) return 0;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;ll c = (a * b)%mod;return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(2e6 + 7)] , inv_fac[(int)(2e6 + 7)];
void precomp_factorial(){fac[0] = 1;for(ll i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(ll i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};


int main() {
    
   int n, k;
   cin >> n >> k;
   vector <int> vec(n);
   int cnt = 0;
   for(int i = 0; i < n; i++){
       cin >> vec[i];
       if(vec[i] >= k) cnt++;
   }
   cout << cnt;
}


Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  D2(x)       { cerr << "[" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }
#define  all(x)      (x).begin(), (x).end()
#define  mem(a)      memset(a , 0 ,sizeof a)
#define  deb(x)      cout << #x << " - " << x << "\n";
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcount(x)
#define  deb2(x,y)   cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
 
#define PI 3.141592653589793
const ll p = 5;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

void solve(){
    ll n,d; cin>> n >> d;
    vpll v(n);
    rep(i,0,n) cin >> v[i].ff >> v[i].ss;
    
    ll cnt = 0;
    rep(i,0,n){
        ll temp1 = (v[i].ff*v[i].ff) + (v[i].ss*v[i].ss);
        ll temp = ceil(sqrt(temp1));
        cnt += (temp<=d);
    }
    
    cout << cnt;
}
 
int main() {
    IOS;
    // int t; cin >> t;
    int t=1; 
    while(t--) solve();
    return 0;
}

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

int main(int argc, char const *argv[]) {
    int n, a, b;
    cin >> n >> a >> b;
    if(n*a<b){
        cout << n*a << endl;
    }else{
        cout << b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
#include <stack>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 998244353//1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 200005
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
//template <class T> void add(int &a,T b){a=(a+b)%mod;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}
int pow(int a, int b, int c){
    int ans = 1;
    while(b){
        if(b&1)ans = 1LL * ans * a % c;
        a = 1LL * a * a % c;
        b >>= 1;
    }
    return ans;
}

int a[N], b[N];
int main(){
    int T, m, i, j, k, n, K;
    scanf("%d", &n);
    set<pii>s;
    rep(i, 0, n)scanf("%d", &a[i]);
    rep(i, 0, n){
        scanf("%d", &b[i]);
    }
    rep(i, 0, n){
        if(b[i] < a[i]){
            puts("-1");
            return 0;
        }
        else if(b[i] > a[i]){
            s.insert({b[i], i});
        }
    }
    ll ans = 0;
    while(!s.empty()){
        auto it = s.end();it--;
        i = it->y;
        s.erase(it);
        j = (i-1+n) % n;
        k = (i+1) % n;
        int dv = b[j] + b[k];
        int v = b[i] - a[i];
        if(a[i] >= dv){
            if(v % dv){
                puts("-1");return 0;
            }
            ans += v / dv;
            b[i] = a[i];
            continue;
        }
        else{
            K = b[i] / dv;
            if(K == 0)K = 1;
            ans += K;
            b[i] -= K * dv;
        }
        if(b[i] < a[i]){
            puts("-1");
            return 0;
        }
        else if(b[i] > a[i])s.insert({b[i], i});
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 11136
#include <stdio.h>

long Dif3(long a, long b, long c) {
  long min = a;
  long max = a;
  if (b < min) {
    min = b;
  }
  if (c < min) {
    min = c;
  }
  if (b > max) {
    max = b;
  }
  if (c > max) {
    max = c;
  }
  long ans = max-min;
  return ans;
}

int main(void) {

  long h,w;
  scanf("%ld %ld", &h, &w);
  long min = h*w;
  long a,b,c;
  long other,short_side,dif;
  for (long i = 1; i*2 <= w; i++) {
    a = i*h;
    other = w-i;
    if (other%2 == 0 || h%2 == 0) {
      b = other*h/2;
      c = b;
    } else {
      short_side = other;
      if (h < short_side) {
        short_side = h;
      }
      b = (other*h+short_side)/2;
      c = other*h-b;
    }
    dif = Dif3(a,b,c);
    if (dif < min) {
      min = dif;
    }
  }
  for (long i = 1; i*2 <= h; i++) {
    a = i*w;
    other = h-i;
    if (other%2 == 0 || w%2 == 0) {
      b = other*w/2;
      c = b;
    } else {
      short_side = other;
      if (w < short_side) {
        short_side = w;
      }
      b = (other*w+short_side)/2;
      c = other*w-b;
    }
    dif = Dif3(a,b,c);
    if (dif < min) {
      min = dif;
    }
  }
  printf("%ld\n", min);

  return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

// https://atcoder.jp/contests/abc142/tasks/abc142_b
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();

		List<Integer> listH = new ArrayList<Integer>();
		for(int i=0;i<N;i++) {
			listH.add(sc.nextInt());
		}

		sc.close();

		int result = 0;
		for(int height:listH) {
			if(height>=K) {
				result++;
			}
		}

		System.out.println(result);

	}

}


Measured memory_bytes: 52864
#include <iostream>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


int a, b, c;
int cnt;

int main(void) {
  cin >> a >> b >> c;

  cnt = 0;
  REP(i, a, b + 1) {
    if(c % i == 0) cnt++;
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>

int main(){
        int fh, fm, lh, lm, k;

        scanf("%d %d %d %d %d", &fh, &fm, &lh, &lm, &k);

        int minute;

        minute=(lh*60+lm)-(fh*60+fm)-k;

        printf("%d", minute);

        return 0;
}



Measured memory_bytes: 1728
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/
int main(){
    ll N,K,S;
    cin >> N >> K >> S;//N>=  sum -> S   Kko
    if(S == 1000000000){
        vector<ll> num(N,1);
        rep(i,K){
            num[i] = 1000000000;
        }
        rep(i,N)cout << num[i] << " ";
        cout << endl;
        return 0;
    }
    vector<ll> ans(N,1000000000);
    rep(i,K){
        ans[i] = S;
    }
    rep(i,N){
        cout << ans[i] << " ";
    }
    cout << endl;
}

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

vector<int> tensin(int n) {
	vector<int> ans(5);
	ans[0] = n % 10;
	n /= 10;
	ans[1] = n % 10;
	n /= 10;
	ans[2] = n % 10;
	n /= 10;
	ans[3] = n % 10;
	n /= 10;
	ans[4] = n % 10;
	return ans;
}

int main()
{
	int A, B;
	cin >> A >> B;
	int ans = 0;
	for (int i = A; i <= B; i++) {
		if (tensin(i)[0] == tensin(i)[4] && tensin(i)[1] == tensin(i)[3]) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    
    
    int x = A%B;
    bool can = false;
    
    
    if (x ==0) {
        cout << "NO" << endl;
        exit(0);
    }
    
    for (int n=1; n <B; n++) {
        int y = (n * x)%B;
        
        if (y == C) {
            can = true;
            break;
        }
    }

    
    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 256
// ALDS1_7_A: Rooted Trees

use std::str::FromStr;

fn scan<T: FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn scan_vec<T: FromStr>() -> Vec<T> {
    let s: String = scan();
    s.split_whitespace().map(|a| T::from_str(a).ok().unwrap()).collect()
}

struct Node { 
    p: Option<usize>, 
    l: Option<usize>, 
    r: Option<usize>, 
}

impl Node {
    fn new() -> Node {
        Node { p: None, l: None, r: None }
    }
}

fn print(d: &Vec<usize>, t: &Vec<Node>, u: usize) {
    print!("node {}: ", u);
    match t[u].p {
        Some(p) => print!("parent = {}, ", p),
        None => print!("parent = -1, "),
    }
    print!("depth = {}, ", d[u]);
    if t[u].p == None {
        print!("root, ");
    } else if t[u].l == None {
        print!("leaf, ");
    } else {
        print!("internal node, ");
    }
    print!("[");
    if let Some(l) = t[u].l {
        let mut c = l;
        print!("{}", c);
        while let Some(r) = t[c].r {
            print!(", {}", r);
            c = r;
        }
    }
    println!("]");
}

fn rec(d: &mut Vec<usize>, t: &Vec<Node>, u: usize, p: usize) {
    d[u] = p;
    if let Some(r) = t[u].r {
        rec(d, t, r, p);
    }
    if let Some(l) = t[u].l {
        rec(d, t, l, p + 1);
    }
}

fn main() {
    let n: usize = scan();
    let mut t: Vec<Node> = Vec::new();

    for _ in 0..n {
        t.push(Node::new())
    }

    for _ in 0..n {
        let a: Vec<usize> = scan_vec();
        let v = a[0];
        let d = a[1];
        let mut l = 0;
        for j in 0..d {
            let c = a[j + 2];
            if j == 0 {
                t[v].l = Some(c);
            } else {
                t[l].r = Some(c);
            }
            l = c;
            t[c].p = Some(v);
        }
    }

    let mut r = 0;
    for i in 0..n {
        if t[i].p == None {
            r = i;
        }
    }

    let mut d: Vec<usize> = vec![0; n];
    rec(&mut d, &t, r, 0);

    for i in 0..n {
        print(&d, &t, i);
    }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)

int main(){
    int n;
    cin>>n;
    map<string,int>mp;
    rep(i,n){
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 3628
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    // 逆から考える
    A.reverse();
    
    let answer = [];
    let list = [];
    
    for(let i in A) {
        let alreadyIn = 0;
        
        for(let j=i-(N - i); j>=0; j -= (N - i)) {
            if(list[j] === 1) {
                alreadyIn++;
            }
        }

        if(alreadyIn % 2 === 0) {
            if(A[i] !== 0) {
				answer.push(N - i);
				list.push(1);
            } else {
                list.push(0);
            }
        } else {
            if(A[i] === 0) {
                answer.push(N - i);
                list.push(1);
            } else {
                list.push(0);
            }
        }
    }

    const cnt = answer.length;
    answer.sort((a,b)=>a-b);

    console.log(cnt);
    console.log(answer.join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 37680
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	scanner.Split(bufio.ScanWords)
	n := nextInt()
	q := nextInt()
	A_slices := make([][]int, n)
	for i := 0; i < n; i++ {
		A_slices[i] = make([]int, 0)
	}
	for i := 0; i < q; i++ {
		// fmt.Println(A_slices)
		switch nextInt() {
		case 0:
			t := nextInt()
			x := nextInt()
			A_slices[t] = append(A_slices[t], x)
			// fmt.Println(A_slices)
		case 1:
			t := nextInt()
			if len(A_slices[t]) == 0 {
				continue
			}
			top := A_slices[t][0]
			fmt.Println(top)
		case 2:
			t := nextInt()
			if len(A_slices[t]) == 0 {
				continue
			}
			A_slices[t] = A_slices[t][1:]
		default:
			panic("no such operation!")
		}
	}
}


Measured memory_bytes: 10524
#include<iostream>
#include<cmath>

using namespace std;
int main()
{
    int sh,sm,ss,eh,em,es;
    for(int i=0;i<3;i++){
        cin >> sh >> sm >> ss >> eh >> em >> es;
        int cnt=eh*3600+em*60+es-sh*3600-sm*60-ss;
        cout << cnt/3600 << " " << (cnt%3600)/60 << " " << (cnt%3600)%60 << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3104