akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll= long long;

string S;

int main()
{
    
    cin >> S;

    int l=S.size();
    reverse(S.begin(),S.end());
    ll count=0;
    int j;
    int n;
    int b[10];
    ll ten;
    rep(i,10){
        b[i]=0;
    }
    rep(i,pow(2,l-1)){
        for(j=0,n=i;n>0;j++){
            b[j]=n%2;
            n=n/2;
        }
        for(int k=j;k<S.size()-1;k++)b[k]=0;
        for(j=0,ten=1;j<S.size();j++){
            count+=(S[j]-'0')*ten;
            if(j<S.size()-1){
                if(b[j]==1){
                    ten=1;
                }else{
                    ten*=10;
                }
            }

        }
    }
    cout << count << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M, Q;
  cin >> N >> M >> Q;
  int a[Q], b[Q], c[Q];
  long long d[Q];
  for (int i = 0; i < Q; i++)
    cin >> a[i] >> b[i] >> c[i] >> d[i], a[i]--, b[i]--;
  vector<vector<int>> cand;
  function<void(int, vector<int> &)> rec = [&](int i, vector<int> &A) {
    if (i == N) {
      cand.push_back(A);
    } else {
      for (int j = A.size() ? A.back() : 1; j <= M; j++) {
        A.push_back(j);
        rec(i + 1, A);
        A.pop_back();
      }
    }
  };
  vector<int> tmp;
  rec(0, tmp);
  long long ans = 0;
  for (auto A : cand) {
    long long score = 0;
    for (int i = 0; i < Q; i++) {
      if (A[b[i]] - A[a[i]] == c[i]) score += d[i];
    }
    ans = max(ans, score);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9772
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#ifdef LOCAL_ENV
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define DUMP(x)
#define DEBUG(x)
#endif

#define MAX_VALUE 9223372036854775807

int solve() {
	ll N, X, T;
	cin >> N >> X >> T;

	RET(T * ((N + X - 1) / X));

	return 0;
}

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

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
int main()
{
  int k=0,a=0,b=0;
  int i=0;
  
  scanf("%d",&k);
  scanf("%d %d",&a,&b);
 
  i=1;
  while(k<=a)
  {
    if(a<=k*i){
      break;
    }
    i++;
  }
 // printf("%d",i);
  if(k*i<=b){
    printf("OK\n");
  }
  else{
    printf("NG\n");
  }
  return 0;
}

Measured memory_bytes: 1660
import java.util.Scanner;

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

		int counter = 0;
		int maxw = Integer.parseInt(sc.nextLine());
		while (maxw != 0) {
			counter++;
			
			int num = Integer.parseInt(sc.nextLine());

			int[][] table = new int[num + 1][maxw + 1];
			for (int i = 0; i < table.length; i++) {
				for (int j = 0; j < table[0].length; j++) {
					table[i][j] = 0;
				}
			}
			
			int value, w;
			for (int i = 0; i < num; i++) {
				String[] nico = sc.nextLine().split(",");

				value = Integer.parseInt(nico[0]);
				w = Integer.parseInt(nico[1]);
				
				for (int j = 0; j < table[0].length; j++) {
					if ((j - w) >= 0) {
						if (table[i][j] > (table[i][j - w] + value)) table[i + 1][j] = table[i][j];
						else table[i + 1][j] = table[i][j - w] + value;
					} else {
						table[i + 1][j] = table[i][j];
					}
				}
			}
			
			int max = 0;
			int index = 0;
			for (int i = 0; i < table[0].length; i++) {
				if (max < table[num][i]) {
					max = table[num][i];
					index = i;
				}
			}

			System.out.println("Case " + counter + ":");
			System.out.println(max);
			System.out.println(index);
			
			maxw = Integer.parseInt(sc.nextLine());
		}
	}
}

Measured memory_bytes: 37416
//https://atcoder.jp/contests/dp/tasks/dp_f

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


#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

typedef long long int ll;

const int precision = 16;
const int modulo =  1000000007; // 10^9 + 7
using ll = long long;
const double EPS = 1e-9;
//const ll INF = 1e18L + 5;
const int INF = 1e9 + 5;

string solveLCS() 
{
	string s, t;  cin >> s >> t;

	vector<vector<int>> dp(s.size() + 1, vector<int> (t.size() + 1, 0));

	for(auto i = 0; i <= (int)s.size(); ++i) {
		dp[i][0] = i;
	}

	for(auto i = 0; i <= (int)t.size(); ++i) {
		dp[0][i] = i;
	}


	for(auto r = 1; r <= (int)s.size(); ++r) {
		for(auto c = 1; c <= (int)t.size(); ++c) {
			if(s[r - 1] == t[c - 1]) {
				dp[r][c] = dp[r - 1][c - 1];
			} else {
				dp[r][c] = min(dp[r - 1][c], dp[r][c - 1]) + 1;
			}
		}
	}

 
	int r = s.size(), c = t.size();

	string ret = "";
	while(r > 0 and c > 0) {
		if(s[r - 1] == t[c - 1]){
			ret += s[r - 1];
			r--;
			c--;
		} else {
			if(dp[r - 1][c] < dp[r][c - 1]) {
				r = r - 1;
			} else {
				c = c - 1;
			}
		}
	}

	reverse(ret.begin(), ret.end());
	return ret;
}

template <typename T>
void max_self(T & a, T b) {
	a = max(a,b);
}

bool first_row_or_column(pair<int, int> p) {
	return p.first == 0 or p.second == 0;
}

string solveLCS_by_errichto() {
	 string a, b;  cin >> a >> b;
	vector<vector<pair<int, pair<int, int>>>> dp(a.size() + 1, 
		vector<pair<int, pair<int, int>>>(b.size() + 1, {-INF, {0,0}}));

	dp[0][0] = {0, {0,0}};
	//dp[i][j] - the max total length so far

	for(int i = 0; i < (int) a.size(); ++i) {
		for(int j = 0; j < (int) b.size(); ++j) {
			if(a[i] == b[j]) {
				max_self(dp[i + 1][j + 1], make_pair(dp[i][j].first + 1, make_pair(i, j)));
			}

			max_self(dp[i + 1][j], make_pair(dp[i][j].first, make_pair(i, j)));
			max_self(dp[i][j + 1], make_pair(dp[i][j].first, make_pair(i, j)));
		}
	}

	pair<int, pair<int, int>> answer = {0, {0, 0}};
	for(int i = 0; i <= (int) a.size(); ++i) {
		for(int j = 0; j <= (int) b.size(); ++j) {
			max_self(answer, make_pair(dp[i][j].first, make_pair(i, j)));
		}
	}


	string s;
	pair<int, int> cur = answer.second;
	while(!first_row_or_column(cur)){
		int i = cur.first;
		int j = cur.second;
		pair<int, int> prev = dp[i][j].second; //a cell from wich we came to (i, j)
		if(prev == make_pair(i - 1, j - 1)){
			assert(a[i - 1] == b[j - 1]);
			s += a[i - 1];
		}

		cur = prev;
	}
	reverse(s.begin(), s.end());
	return s;


}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(precision);
	cout.setf(ios_base::fixed);

	//auto ret = solveLCS();
	auto ret = solveLCS_by_errichto();
	cout << ret;
	return 0;
}




Measured memory_bytes: 105984
use std::cmp;
use std::io::Read;

fn gcd(a: i64, b: i64) -> i64 {
    if a == 0 {
        b
    } else if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n = iter.next().unwrap().parse().unwrap();

    let mut beams = (0..n)
        .map(|_| {
            let a: i64 = iter.next().unwrap().parse().unwrap();
            let b: i64 = iter.next().unwrap().parse().unwrap();
            (a, b)
        })
        .collect::<Vec<(i64, i64)>>();
    let target_sum: i64 = beams.iter().map(|&(a, _)| a).sum();

    beams.sort_by(|&(a1, b1), &(a2, b2)| {
        let max1 = cmp::max(a1, b1);
        let max2 = cmp::max(a2, b2);
        max2.cmp(&max1)
    });

    let mut k = 0;
    let mut sum = 0;
    while sum < target_sum {
        sum += cmp::max(beams[k].0, beams[k].1);
        k += 1;
    }

    let mut num: i64 = 0;
    let mut den: i64 = 1;
    for i in 0..n {
        let ind = cmp::min(k - 1, i);
        let rest = target_sum - (sum - cmp::max(beams[ind].0, beams[ind].1));
        if rest <= beams[i].1 {
            let tmp_num = beams[i].1 - rest;
            let tmp_den = beams[i].1;
            if tmp_num * den > tmp_den * num {
                num = tmp_num;
                den = tmp_den;
            }
        }
    }
    num = (n - k) as i64 * den + num;
    den *= n as i64;
    let d = gcd(num, den);
    println!("{} {}", num / d, den / d);
}


Measured memory_bytes: 8444
from collections import deque
N, Q = map(int, input().split())
edges = [[] for i in range(N+1)]
counts = [0 for i in range(N+1)]

for i in range(N-1):
  a, b = map(int, input().split())
  edges[a].append(b)
  edges[b].append(a)

for j in range(Q):
  p, x = map(int, input().split())
  counts[p] += x

def dfs():
  colors = ["white"] * (N+1)
  stack = deque()
  stack.append(1)

  while stack:
    v = stack.pop()
    colors[v] = "black"

    for e in edges[v]:
      if colors[e] != "black" and e != v:
        counts[e] += counts[v]
        stack.append(e)

dfs()

print(*counts[1:])

Measured memory_bytes: 56008
#include<bits/stdc++.h>
#define lp(i,n) for(int i=0;i<n;i++)
#define INF (1<<28)
using namespace std;
int main(){
  cout << fixed << setprecision(10);
  int n;
  cin>>n;
  vector<vector<int> > v;
  lp(i,n){
    int f,a,b,c,d;
    cin>>f>>a>>b>>c>>d;
    vector<int> h={f,a,b,c,d};
    v.push_back(h);
  }
  double ansd=-1,ansdd=-1;
  double anst=INF,anstt=INF;
  lp(i,n){
    if(i==0) continue;
    if(v[i][2]!=v[i-1][2]) continue;
    if(v[i][1]!=v[i-1][1]){
      double dis=(double)sqrt(pow(abs(v[i][4]-v[i-1][4]),2)+pow(abs(v[i][3]-v[i-1][3]),2));
      int t=v[i][0]-v[i-1][0];
      if(dis>ansd&&v[i][2]==0){
	ansd=dis;
	anst=t;
      }
      if(dis>ansdd&&v[i][2]==1){
	ansdd=dis;
	anstt=t;
      }
      if(dis==ansd&&t<anst&&v[i][2]==0){
	ansd=dis;
	anst=t;
      }
      if(dis==ansdd&&t<anstt&&v[i][2]==1){
	ansdd=dis;
	anstt=t;
      }
    }
  }
  if(anst==INF) cout<<-1<<" "<<-1<<endl;
  else cout<<ansd<<" "<<anst/60.0<<endl;
  if(anstt==INF) cout<<-1<<" "<<-1<<endl;
  else cout<<ansdd<<" "<<anstt/60.0<<endl;
  return 0;
}



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

int main(void){

double N, K;
double a = 0.0;
double count = 0.0;
double sum = 0.0;
double e = 0.0;
double b;

scanf("%lf", &N);
scanf("%lf", &K);


for(a = 1; a <= N; a++){
  count = 0.0;
  b = a;
    while(b < K){
        b = b * 2.0;
        count += 1;
    }
  e = pow(0.5, count);
  sum += 1/N * e;
}

printf("%.12f\n", sum);


return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
    
      Scanner in = new Scanner(System.in);
	int n = in.nextInt();
	int k = in.nextInt();

	int[] arr = new int[n];

	for(int i =0; i<n;i++)
		arr[i] = in.nextInt();

	boolean[] dp = new boolean[k+1];
	Arrays.fill(dp, false);

	for(int i = 1; i<=k; i++){
		for(int j =0; j<n; j++){
			if(i< arr[j]) break;

			if(!dp[i-arr[j]]){
				dp[i] = true;
				break;
			}
		}
	}
	System.out.println(dp[k]? "First": "Second");
      
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main(){
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; i+=2) {
        int cnt = 0;
        for(int j = 1; j <= i; j++) {
            if(i%j == 0) {
                cnt++;
            }
        }
        if(cnt == 8) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3676
#include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>

using namespace std;

int main(){
    int len_array,num_query;
    int key;
    scanf("%d",&len_array);
    vector<int> int_array(len_array);
    for(int i = 0;i < len_array;i++){
        cin >> int_array[i];
    }
    
    scanf("%d",&num_query);
    for(int i = 0;i < num_query;i++){
        scanf("%d",&key);
        vector<int>::iterator itr1 = lower_bound(int_array.begin(),int_array.end(),key);
        vector<int>::iterator itr2 = upper_bound(int_array.begin(),int_array.end(),key);
        cout << itr1-int_array.begin() << " " << itr2-int_array.begin() << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 3484
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <cstdio>
typedef long long ll;
#define INF 0x3f3f3f3f

using namespace std;

int gcd(int a, int b) {
	return b == 0? a: gcd(b, a % b);
}
int A[100000 + 10];
void solve() {
	int N, K;
	while(~scanf("%d%d", &N, &K)) {
		int max_num = 0;
		for(int i = 0; i < N; i++) {
			scanf("%d", A + i);
			if(A[i] == K) {
				puts("POSSIBLE");
				return;
			}
			if(A[i] > max_num)
				max_num = A[i];
		}
		
		if(K > max_num) {
			puts("IMPOSSIBLE");
			return;
		}
		
		if(N == 1) {
			if(K == A[0]) {
				puts("POSSIBLE");
			}else {
				puts("IMPOSSIBLE");
			}
		}else {
			int cd = gcd(A[0], A[1]);
			for(int i = 2; i < N; i++) {
				cd = gcd(cd, A[i]);
			}
			for(int i = 0; i < N; i++) {
				if( (A[i] - K) % cd == 0) {
					puts("POSSIBLE");
					return;
				}
			}
			puts("IMPOSSIBLE");
		}
	}
}
int main(int argc, char *argv[]) {
	solve();
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int x, y;
    cin >> x >> y;
    for (int i = 0; i < 100; i++)
    {
        for (int j = 0; j < 100; j++)
        {
            if (i * 4 + j * 2 == y && i + j == x)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3596
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;

static class P
{
    static void Main()
    {
        var nabcd = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nabcd[0];
        var a = nabcd[1];
        var b = nabcd[2];
        var c = nabcd[3];
        var d = nabcd[4];
        string s = Console.ReadLine();
        //確実に踏まなければいけない場所
        //abcd
        //acbd
        if (a < b && b < c && c < d || a < c && c < b && b < d)
        {
            if (!s.Substring(a - 1, c - a + 1).Contains("##") && !s.Substring(b - 1, d - b + 1).Contains("##"))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
        //abdc
        else if (a < b && b < d && d < c)
        {
            if (!s.Substring(a - 1, c - a + 1).Contains("##") && !s.Substring(b - 1, d - b + 1).Contains("##") && s.Substring(b - 2, (d + 2) - b + 1).Contains("..."))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
        else
        {
            throw new Exception();
        }
    }
}


Measured memory_bytes: 12384
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

int main()
{
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int n,a,b,c,d;scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	a=abs(a-b);
	int l=0,r=n;
	while (l<=r)
    {
        int mid=(l+r)>>1;
        if (ll(mid)*c-ll(n-1-mid)*d>a) r=mid-1; else l=mid+1;
    }
    if (ll(r)*d-ll(n-1-r)*c>=a) puts("YES"); else puts("NO");
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e12;

// computational complexity : O(V^3)

int V,E;// number of (vertices, edges)
vector<vector<long long int>> d;// d[i][j] = shortest distances between i and j

int main(){
    int L;
    cin >> V >> E >> L;
    d.assign(V, vector<long long int>(V, INF));
    for(int i=0; i<V; i++){
        d[i][i] = 0;
    }

    for(int i=0; i<E; i++){
        int u, v, w;
        cin >> u >> v >> w;
        u -= 1;
        v -= 1;
        if(w > L) continue;

        d[u][v] = w;
        d[v][u] = w;
    }

    // naive DP
    for(int k=0; k<V; k++){// potential relay points
        for (int i=0; i<V; i++){
            for (int j=0; j<V; j++){
                d[i][j] = min(
                    d[i][j],// without going through k
                    d[i][k] + d[k][j]// with going through k
                );
            }
        }
    }

    // another Warshall-Floyd
    vector<vector<long long int>> d_original = d;
    d.assign(V, vector<long long int>(V, INF));
    for(int i=0; i<V; i++){
        d[i][i] = 0;
    }
    for (int i=0; i<V; i++){
        for (int j=0; j<V; j++){
            if(d_original[i][j] <= L){
                d[i][j] = 1;
                d[j][i] = 1;
            }
        }
    }
    for(int k=0; k<V; k++){// potential relay points
        for (int i=0; i<V; i++){
            for (int j=0; j<V; j++){
                d[i][j] = min(
                    d[i][j],// without going through k
                    d[i][k] + d[k][j]// with going through k
                );
            }
        }
    }

    int Q;
    cin >> Q;
    for(int q=0; q<Q; q++){
        int s, t;
        cin >> s >> t;
        s -= 1;
        t -= 1;
        if(d[s][t] == INF) cout << -1 << endl;
        if(d[s][t] != INF) cout << d[s][t] - 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 5068
#include<stdio.h>

int main(){
  char s[200001];
  int i = 0, len = 0;
  
  scanf("%s", s);
  while(s[len]){
    len++;
  }
  while(1){
    if(s[i++] == 'A'){
      break;
    }
  }
  
  while(1){
    if(s[len--] == 'Z'){
      break;
    }
  }
  
  printf("%d\n", len - i + 3);
  
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int n,count = 0;
	cin >> n;
	vector<int> v(n);
	r(i,n){
      cin >>v.at(i);
      count+=v.at(i)-1;
    }
  cout << count << endl;
}


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

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

    int n;
    cin >> n;
    map <string, int> mp;

    FOR(i, n){
    	string s;
    	cin >> s;

    	sort(ALL(s));
    	mp[s]++;
    }

    ll ans = 0;
    for(auto p:mp){
    	ans += (ll) p.second*(p.second - 1)/2;
    }

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


Measured memory_bytes: 11264
package main

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

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - Big Array
	var N, K int
	fmt.Scan(&N, &K)

	sc.Split(bufio.ScanWords)
	var a, b int
	c := make(map[int]int, N)
	for i := 0; i < N; i++ {
		a, b = nextInt(), nextInt()
		c[a] += b
	}

	A := make([]int, 0)
	for i := range c {
		A = append(A, i)
	}

	sort.Sort(sort.IntSlice(A))
	var count int
	for i := 0; i < len(A); i++ {
		//fmt.Println(count, A[i], c[A[i]])
		count += c[A[i]]
		if K <= count {
			fmt.Println(A[i])
			break
		}
	}
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  string s;
  cin >> s;
  int count = s.size(), win = 0;
  REP(i, count) {
    if (s[i] == 'o') win++;
  }
  if (win + 15 - count >= 8) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
n,d,a = map(int,input().split())
raw = []
event = []
for i in range(n):
  x,h = map(int,input().split())
  event.append([x,0,i,h])
for i in range(n):
  tmp = event[i][0] + 2 * d
  event.append([tmp,1,i])
event.sort()
#print(event)
use = [0 for _ in range(n)]
now = 0
ans = 0
for j in range(2*n):
  x,d,i = event[j][:3]
  if d == 0:
    h = event[j][3]
    if h <= now * a:
      pass
    else:
      h -= now * a
      tmp = (h-1)//a+1
      now += tmp
      use[i] = tmp
      ans += tmp
  else:
    now -= use[i]
  #print(x,d,i,ans,now)
print(ans)

Measured memory_bytes: 86724
a,b,c = map(int,input().split())

if a%2==b%2==c%2:
  print((3*max(a,b,c)- a-b-c)//2)
  exit()
elif a%2==b%2:
  a += 1
  b += 1
  print((3*max(a,b,c)- a-b-c)//2 + 1)
  exit()
elif c%2==b%2:
  c += 1
  b += 1
  print((3*max(a,b,c)- a-b-c)//2 + 1)
  exit()
else:
  c += 1
  a += 1
  print((3*max(a,b,c)- a-b-c)//2 + 1)
  exit()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    int val =1;
    int a=0;
    int b=0;
    for (int i=0;i<n;i++){
        a = val * 2;
        b = val + k;
        if (a > b){
            val = b;
        }else{
            val=a;
        }
    }
    cout << val << endl;
}

Measured memory_bytes: 256
#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, t, a;
    cin >> n >> t >> a;
    vector<double> diff(n);
    rep(i,n) {
        int h; cin >> h;
        diff[i] = abs(t - h * 0.006 - a);
    }
    int ans = min_element(diff.begin(), diff.end()) - diff.begin() + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int p=1e9+7;
int n,i,l,r,w,al,ar,dl,dr,f[102][102][102],a[102],ans;
int main(){
	scanf("%d",&n);
	for(i=1;i<=n*2-1;i++)scanf("%d",&a[i]);
	sort(a+1,a+n*2);
	f[n][1][0]=1;
	for(i=n-1;i;i--){
		al=(a[i]!=a[i+1]);ar=(a[n*2-i]!=a[n*2-i-1]);
		for(l=0;l<=n*2-1;l++)
		 for(r=0;r+l<=n*2-1;r++)if(f[i+1][l][r]){
		 	w=f[i+1][l][r];
		 	for(dl=1;dl<=l+al;dl++)(f[i][l+al+1-dl][r+ar+(dl>1)]+=w)%=p;
		 	for(dr=1;dr<=r+ar;dr++)(f[i][l+al+1][r+ar-dr]+=w)%=p;
		 }
	}
	for(l=0;l<=n*2-1;l++)
	 for(r=0;l+r<=n*2-1;r++)ans=(ans+=f[1][l][r])%=p;
	printf("%d",ans);
}

Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <cstdio>
#include <iostream>
#include <string>
#include <fstream>
#include <queue>
#include <cmath>
using namespace std;


int main(void) {
	
	int N;
	cin >> N;
	vector<long int>A(N);
	int i = 0,c=0;
	while (i<N) {
		cin >> A[i];
		i++;
	}
	i = 0;
	while (A[i] % 2 == 0) {
	
		A[i] /= 2;
		i++;
		if (i == N) {
			i = 0;
			c++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;

int main(){
    int b, f, r, v;
    int n;
    cin >> n;
    int info[4][3][10]; // 棟　フロア　部屋番号

    for(int build=0;build<4;build++){
        for(int floor=0;floor<3;floor++){
            for(int room=0;room<10;room++){
                info[build][floor][room] = 0;
            }
        }
    }

    for(int i=0;i<n;i++){
        cin >> b >> f >> r >> v;
        info[b-1][f-1][r-1] += v;
    }

    for(int build=0;build<4;build++){
        for(int floor=0;floor<3;floor++){
            for(int room=0;room<10;room++){
                cout << " " << info[build][floor][room];
            }
            cout << endl;
        }
        if(build != 3)cout << "####################" << endl;
    }
}


Measured memory_bytes: 3092
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

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

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
	string s_d; cin >> s_d;
	string t; cin >> t;
	string x = "UNRESTORABLE";
	int j;
	for (int i = s_d.length() - t.length(); i > -1; i--) {
		for (j = 0; j < t.length(); ++j) {
			if (s_d[i + j] != '?' && s_d[i + j] != t[j]) {
				break;
			}
		}
		if (j == t.length()) {
			x = s_d;
			for (unsigned int k = 0; k < t.length(); ++k) {
				x[i + k] = t[k];
			}
			for (unsigned int k = 0; k < x.length(); ++k) {
				if (x[k] == '?') x[k] = 'a';
			}
			break;
		}
	}
	cout << x << endl;
    return;
}

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



Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int n,i,A[100];
  
  scanf("%d",&n);

  A[0] = 1;
  A[1] = 1;

  for(i=2;i<=n;i++){
    A[i] = A[i-1] + A[i-2];
  }
  

  printf("%d\n",A[n]);

  return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <stack>
#include <cstdio>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#define popcount(x) __builtin_popcount(x)
#define oddparity(x) __builtin_parity(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define sf scanf
#define pf printf
#define ll long long int
using namespace std;

int i;
ll n, m;

int fact(ll x)
{
    if (x == 1) return 1;
    return (x * fact(x-1)) % 1000000007;
}

int main()
{
    sf("%lld%lld", &n, &m);
    if (abs(n-m) == 1) {
        ll n1 = 1, m1 = 1;
        for (i = 1; i <= n; i++) {
            n1 = (n1 * i) % 1000000007;
        }
        for (i = 1; i <= m; i++) {
            m1 = (m1 * i) % 1000000007;
        }
        pf("%d\n", (n1 * m1) % 1000000007);
    }
    else if (n == m) {
        ll n1 = 1;
        for (i = 1; i <= n; i++) {
            n1 = (n1 * i) % 1000000007;
        }
        pf("%d\n", (2 * n1 * n1) % 1000000007);
    }
    else {
        pf("0\n");
    }
    return 0;
}

Measured memory_bytes: 256
S = list(map(int,input().split()))
a = S[0]
b = S[1]
if a == b:
  for i in range(int(a)):
    print(a,end="")
elif a > b:
  for i in range(int(a)):
    print(b,end="")
else:
  for i in range(int(b)):
    print(a,end="")

Measured memory_bytes: 3060
n = int(input())
for i in range(n):
    i=i+1
    x=i
    if (x%3==0):
        print(" {}".format(i),end="")
    else:
        while True:
            if (x%10==3):
                print(" {}".format(i), end="")
                break
            x=x//10
            if (x==0):
                break
print()


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

int main()
{
  int A,B,C,X,Y;
  cin >>A>>B>>C>>X>>Y;

  int sum;
  int min=1000000000;

  for(int i=0; i<=max(X,Y);i++)
  {
    sum=2*i*C+A*max(0,X-i)+B*max(0,Y-i);
    if(min>sum) min=sum;
  }

  cout << min;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var n int 
  fmt.Scan(&n)
  tot := 0
  for i := 0; i < n; i++ {
    var l, r int 
    fmt.Scan(&l, &r)
    tot += r - l + 1
  }
  fmt.Println(tot)
}

Measured memory_bytes: 512
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int time = scanner.nextInt();
		int total=0;
		Deque<Integer> queue = new ArrayDeque<Integer>();
		Deque<String> name = new ArrayDeque<String>();
		for (int i = 0; i < n; i++) {
			name.add(scanner.next());
			queue.add(scanner.nextInt());
		}
		while(true) {
			int num=queue.poll();
			String name1=name.poll();
			num=num-time;
			if(num<=0) {
				total=total+time+num;
				System.out.print(name1+" ");
				System.out.println(total);
				if(name.isEmpty()) {
					break;
				}
			}else {
				total=total+time;
				queue.add(num);
				name.add(name1);
			}
		}
		scanner.close();
	}

}



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

void solve() {
	int n; cin >> n;
	rep(i, 9)rep(j, 9) {
		if (n == (i+1) * (j+1)) {
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
}

int main() {

	solve();

	return 0;
}


Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

VV<ll> edges;

ll dfs(ll cur, ll pre) {
    ll ret = 0;
    for(ll nxt : edges[cur]) {
        if(nxt == pre) continue;
        ret ^= (dfs(nxt, cur) + 1);
    }
    return ret;
}

int main() {
    ll N;
    cin >> N;
    edges.resize(N);
    for(ll i = 1; i < N; i++) {
        ll x, y;
        cin >> x >> y;
        x--; y--;
        edges[x].push_back(y);
        edges[y].push_back(x);
    }
    cout << (dfs(0, -1) ? "Alice" : "Bob") << endl;
    return 0;
}


Measured memory_bytes: 10368
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(),i=1,x;

        while(i<=N){
            x = i;
            if(x%3 == 0){
                System.out.print(" "+i);
            }else{
                while (x > 10) {
                    if (x % 10 == 3 || x/10 == 3) {
                        System.out.print(" " + i);
                        break;
                    }
                    x /= 10;
                }
            }
            i += 1;
        }
        System.out.printf("\n");
    }
}


Measured memory_bytes: 28548
Q, H, S, D = gets.split.map(&:to_i)
bottle = [[Q, 0.25], [H, 0.5], [S, 1.0], [D, 2.0]].sort_by { |cost, size| cost / size }
N = gets.to_i
n = N

ans = 0

while n > 0
  cost, size = bottle.shift

  cnt = (n / size).floor
  ans += cnt * cost
  n -= cnt * size
end

puts ans


Measured memory_bytes: 1788
# N = gets.chomp.to_i
A, B = gets.chomp.split.map(&:to_i)
# A = Array.new(N + 1, 0)  # 0 means no trap, 1 means existence of trap. 1-indexed

if A >= 13
  p B
elsif A >= 6
  p B / 2
else # A <= 5
  p 0
end

Measured memory_bytes: 1788
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)

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

ans = None
for a in As:
    if ans is None:
        ans = a
    else:
        ans = gcd(ans, a)
print(ans)


Measured memory_bytes: 13704
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  for(int i = 0; i < N; i++) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }
  sort(s.begin(), s.end());
  long num = 1;
  long ans = 0;
  for(int i = 1; i < N; i++) {
    if(s[i] == s[i - 1]) num++;
    else {
      if(num > 1) ans += num*(num - 1)/2;
      num = 1;
    }
  }
  if(num > 1) ans += num*(num - 1)/2;
  cout << ans << endl;
}

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

#define M 1000000000000000000

int main()
{
    int n;
    cin >> n;
    string ans = "No";
    rep(i, 10)
        rep(j, 10) if (i * j == n) ans = "Yes";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vp;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define M 1000000007
//---------------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)

//--------------------------------------------------------------

void Main(){
  int n;
  cin>>n;
  vvi msg(n,vi(n,-1));
  rep(i,n){
    int a;
    cin>>a;
    rep(j,a){
      int x,y;
      cin>>x>>y;
      x--;
      msg[i][x] = y;
    }
  }
  int ans=0;
  rep(i,1<<n){
    bitset<16> hone(i);
    bool f=true;
    rep(j,n){
      if(hone[j]==0) continue;
      rep(k,n){
        if(msg[j][k]==-1) continue;
        if(msg[j][k]!=hone[k]){
          f = false;
          break;
        }
      }
      if(!f) break;
    }
    if(f){
      int h=0;
      h+=hone.count();
      maxs(ans,h);
    }
  }
  cout<< ans <<endl;
} int main(int argc,char** argv)
{fastio; myio; myloopset Main();}


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

namespace ABC113A
{
    class Program
    {
            static void Main(string[] args)
            {


                var word = Console.ReadLine().Split();
                int a = int.Parse(word[0]);
                int b = int.Parse(word[1]);
                int max = 0;
            max = a + (b / 2);
                Console.WriteLine(max);
                Console.ReadKey();



            }
        }
    }



Measured memory_bytes: 11092
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long L = sc.nextLong();
		long R = sc.nextLong();
		int minmod = 2020;
		loop: for(long i = L; i < R; i++) {
			for(long j = i + 1; j <= R; j++) {
				minmod = (int) Math.min(minmod, (i % 2019) * (j % 2019) % 2019);
				if(minmod % 2019 == 0) {
					break loop;
				}
			}
		}
		System.out.println(minmod);
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;
int main(){
	IOS;
	int n,k;
	cin>>n>>k;
	int ans=0;
	while(n!=0){
		n/=k;
		ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 3588
N=int(input())
A=list(map(int,input().split()))
mod=10**9+7
if N%2==0:
  B=[2]*(N//2)
  for a in A:
    if a%2!=1:
      print(0);exit()
    B[(a-1)//2]-=1
  if B.count(0)!=N//2:
    print(0)
  else:
    print(pow(2,N//2,mod))
else:
  B=[2]*((N+1)//2)
  for a in A:
    if a%2!=0:
      print(0);exit()
    B[a//2]-=1
  if B[0]!=1:
    print(0)
  else:
    if B.count(0)!=(N+1)//2-1:
      print(0)
    else:
      print(pow(2,(N+1)//2-1,mod))
  
  
  

Measured memory_bytes: 52460
using System;
using System.Collections.Generic;

public class ShellSort
{

	public int cnt = 0;

	// ?????§???????????????????????¢?????´?????????
	public void sort (int[] T, int n)
	{		

		//int[] G = new int[m];
		List<int> G = new List<int>();
					
		// G????¨????
		for (int i = 0; i < n; i++) {
			if (i == 0) {
				//G [i] = 1; // G_0 = ??¨????????????
				G.Add(1);					
				continue;
			}
			int next = 3 * G [i - 1] + 1;
			if (n < next) {
				break;
			}
			G.Add (next);
		}
			
		int m = G.Count;
			
		// G??????????????????????????????(???????????§????????????????????????????????????)		
		G.Reverse ();
				
		for (int i = 0; i < G.Count; i++) {
			insertionSort (T, n, G [i]);
		}			

		// ???????????? 1:m?????? 2:G?????????????????? 3:cnt?????? 4?????\???:?????????????????????
		// 1:m
		Console.WriteLine (m);
		for (int i = 0; i < G.Count; i++) {
			// 2:G
			if (i == G.Count - 1) {
				Console.WriteLine (G [i]);
				continue;
			}
			Console.Write (G [i] + " ");
		}
		// 3:cnt
		Console.WriteLine (cnt);

		// 4:?????????????????????
		for (int i = 0; i < n; i++) {
			Console.WriteLine (T [i]);
		}
	}

	public void insertionSort (int[] T, int n, int g)
	{
		for (int i = g; i < n; i++) {
			int v = T [i];
			int j = i - g;
			while (j >= 0 && T [j] > v) {				
				T [j + g] = T [j];
				j = j - g;
				cnt++;
			}
			T [j + g] = v;
		}
	}

	public static void Main ()
	{
		int N = int.Parse (Console.ReadLine ());
		int[] input = new int[N];
		for (int i = 0; i < N; i++) {
			input [i] = int.Parse (Console.ReadLine ());
		}		
		ShellSort shellSort = new ShellSort ();
		shellSort.sort (input, N);
	}
    
}

Measured memory_bytes: 16540
N, K, Q = gets.split.map &:to_i
ans = Array.new(N, K)
q = Array.new(N, 0)
Q.times do
  q[gets.to_i - 1] += 1
end

ans.each_with_index do |e, idx|
  if e - Q + q[idx] <= 0
    puts 'No'
  else
    puts 'Yes'
  end
end

Measured memory_bytes: 15944
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(void) {
	string s;
	cin>>s;
	string ss;
	cin>>ss;
	rep(i,0,1000){
		string s1;
		rep(j,1,s.sz){
			s1 += s[j];
		}
		s1 += s[0];
		if(ss==s1){
			cout << "Yes" << endl;
			return 0;
		}
		s = s1;
	}
	cout << "No" << endl;
	return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > ps;
  for(int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    ps.emplace_back(x, y);
  }
  sort(ps.begin(), ps.end());
  for(auto p : ps) cout << p.first << " " << p.second << endl;
  return 0;
}



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

int compare(const void *a, const void *b){
  return *(int*)a - *(int*)b;
}

int main(){
  int n, k, h[200000];
  int i, min;

  scanf("%d %d", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%d", &h[i]);
  }

  qsort(h, n, sizeof(int), compare);

  min = h[k-1] - h[0];
  for (i = 0; i <= n-k; i++) {
    if (min > h[k+i-1] - h[i]){
      min = h[k+i-1] - h[i];
    }
  }

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

  return 0;
}


Measured memory_bytes: 892
#include <stdio.h>

int main(void){
    int H, W;
    scanf("%d %d", &H, &W);
    char a[H][W];

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            scanf(" %c", &a[i][j]);
        }
    }
    //FR

    for(int i=0; i<W+2; i++){
        printf("#");
    }
    printf("\n");

    for(int i=0; i<H; i++){
        printf("#");
        for(int j=0; j<W; j++){
            printf("%c", a[i][j]);
        }
        printf("#\n");
    }

    for(int i=0; i<W+2; i++){
        printf("#");
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    int n,w1; cin>>n>>w1;
    int w[n],v[n];
    int s=0;
    for (int i = 0; i < n; ++i)
    {
        cin>>w[i]>>v[i];
        s+=v[i];
    }
    int dp[s+1]={};
    for (int i = 0; i < s; ++i)
    {
        dp[i+1]=1e18;
    }
    for(int j=0; j<n; j++){
        for(int i=s; i>=0; i--){
            if(v[j]<=i){
                dp[i]=min(dp[i],dp[i-v[j]]+w[j]);
                // dp[i]=max(dp[i],dp[i-w[j]]+v[j]);
            }
        }
    }
    int ans=0;
    for (int i = 0; i <= s; ++i)
    {
        if(dp[i]<=w1)
            ans=i;
    }
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

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

const int INF = 1 << 30;

int N;
int h[100009];
int dp[2];

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

    dp[0] = INF;
    dp[1] = 0;
    for(int i = 2; i <= N; i++)
        dp[i & 1] = min(dp[i - 1 & 1] + abs(h[i] - h[i - 1]),
                        dp[i & 1] + abs(h[i] - h[i - 2]));

    cout << dp[N & 1] << endl;

    return 0;
}

Measured memory_bytes: 640