akhauriyash/Code-Regression huggingface dataset:
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}

	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	a := getNextInt64(scanner)
	b := getNextInt64(scanner)
	k := getNextInt64(scanner)

	cm := Com{}
	cm.init(n + 1)
	var ans int64
	for i := 0; i <= n && k-a*int64(i) >= 0; i++ {
		if (k-a*int64(i))%b != 0 {
			continue
		}
		j := (k - a*int64(i)) / b
		if int64(n) < j {
			continue
		}
		ans = mod(ans + mod(cm.calc(n, i)*cm.calc(n, int(j))))
	}

	fmt.Fprintln(writer, ans)
}

func mod(x int64) int64 {
	m := int64(998244353)
	return (x%m + m) % m
}

// Com ...
type Com struct {
	facs, invs []int64
	mod        int64
}

func (cm *Com) init(n int) {
	cm.facs = make([]int64, n+1)
	cm.invs = make([]int64, n+1)

	cm.facs[0] = 1
	cm.mod = int64(998244353)
	for i := 1; i <= n; i++ {
		cm.facs[i] = (cm.facs[i-1] * int64(i)) % cm.mod
	}
	cm.invs[n] = cm.inv(cm.facs[n])
	for i := n - 1; i >= 0; i-- {
		cm.invs[i] = cm.invs[i+1] * int64(i+1) % cm.mod
	}
}

func (cm *Com) inv(n int64) int64 {
	var ii [32]int64
	ii[0] = n
	for i := 1; i < 31; i++ {
		ii[i] = (ii[i-1] * ii[i-1]) % cm.mod
	}
	var ans int64
	ans = 1
	m := cm.mod - 2
	for i := 30; i >= 0; i-- {
		for m >= 1<<uint(i) {
			ans = (ans * ii[i]) % cm.mod
			m -= 1 << uint(i)
		}
	}

	return ans
}

func (cm *Com) calc(n, k int) int64 {
	ans := cm.facs[n] * cm.invs[k]
	ans %= cm.mod
	ans = ans * cm.invs[n-k]
	ans %= cm.mod
	return ans
}


Measured memory_bytes: 7424
while gets
    cards = $_.split(',').map(&:to_i).sort
    max = cards.uniq.map{|x| cards.count x}.max
    min = cards.uniq.map{|x| cards.count x}.min

    case max
    when 4
        puts 'four card'
        next
    when 3
        if min == 2
            puts 'full house'
        else
            puts 'three card'
        end
        next
    when 1
        if (0..3).map { |i| cards[i+1] - cards[i] == 1 }.uniq == [true]
            puts 'straight'
            next
        end
        if cards == [1, 10, 11, 12, 13]
            puts 'straight'
            next
        end
    when 2
        case cards.uniq.size
        when 4
            puts 'one pair'
        when 3
            puts 'two pair'
        end
        next
    end
    puts 'null'
end

Measured memory_bytes: 6108
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int cnt[10100];
    rep(i, N) {
        int K; cin >> K;
        rep(i, K) {
            int A; cin >> A;
            A--;
            cnt[A]++;
        }
    }
    int ans = 0;
    rep(i, M) if(cnt[i] == N) ans++;
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); 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<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll cnt = 0;
    ll ans = 0;
    while (cnt < a && cnt < k) {
      cnt++;
      ans++;
    }
    while (cnt < a+b && cnt < k) {
      cnt++;
    }
    while (cnt < k) {
      cnt++;
      ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, x, y, z);

  int used = z + y + z;
  for (int i = 1;; ++i) {
    if (used > x) {
      cout << i - 1 << endl;
      break;
    }
    used += z + y;
  }

  return 0;
}

Measured memory_bytes: 256
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for(auto i=0; i<(n); i++)
#define repd(i,n) for(auto i=(n)-1; i>=0; i--)
#define repf(i,a,b) for(auto i=(a); i<=(b); i++)
#define repe(i,l) for(auto i: l)
#define mem(x,val) memset((x),(val),sizeof(x));
#define rite(x) freopen(x,"w+",stdout);
#define read(x) freopen(x,"rt",stdin);
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define pb push_back
#define clr clear()
#define INF ((int)0x3f3f3f3f)
#define ins insert
#define xx first
#define yy second
#define eps 1e-9
#define endl '\n'
#define _ ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.precision(10);cout<<fixed;
template<class T> T abs(T x) { return x > 0 ? x : -x; }
template<class T> T mini(T x, T y) { return x <  y? x : y; }
template<class T> T maxi(T x, T y) { return x <  y? y : x; }
template<class T> T gcd(T a, T b) { return a%b? gcd(b, a%b) : b; }
typedef long long i64;
typedef unsigned long long ui64;
typedef string st;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<st> vs;
typedef map<int,int> mii;
typedef map<st,int> msi;
typedef set<int> si;
typedef set<st> ss;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef long long ll;
typedef unsigned long long ull;


int main() {_
	//Solution
	#ifdef LOCAL
		// read("abc097_a.in");
		// rite("abc097_a.out");
	#endif
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if((abs(b-a) <= d && abs(c-b) <= d) || abs(c-a) <= d){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	
	
	
	
	
	
	
	
	
	#ifdef LOCAL
		//cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << endl;
	#endif
   	
	return 0;
}


/*

	g++-6 -std=c++11 abc097_a.cpp -o abc097_a -DLOCAL && ./abc097_a


*/






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

int main() {
int h,w;
cin >> h >>  w;
vector<vector<char>> vec(h,vector<char>(w));
vector<int> a(h,0);
vector<int> b(w,0);

for(int i=0;i<h;i++)
{
    for(int j=0;j<w;j++)
    {
        cin >> vec.at(i).at(j);
    }
}
for(int i=0;i<h;i++)
{
    bool x=true;
    for(int j=0;j<w;j++)
    {
        if(vec.at(i).at(j)=='#')
        {
            x=false;
            break;
        }
    }
    if(x) a.at(i)=1;
}
for(int j=0;j<w;j++)
{
    bool y=true;
    for(int i=0;i<h;i++)
    {
        if(vec.at(i).at(j)=='#')
        {
            y=false;
            break;
        }
    }
    if(y) b.at(j)=1;
}
for(int i=0;i<h;i++)
{
    bool z = false;
    for(int j=0;j<w;j++)
    {
        if(a.at(i)==0 && b.at(j)==0)
        {
            cout << vec.at(i).at(j);
            z = true;
        }
    }
    if(z) cout << endl;
}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	string S;
	cin >> S;

	if (S.length() == 1) {
		cout << 0;
		return 0;
	}

	string temp = S;
	int ans = 1000;
	for (int i = 97; i <= 122; i++) {
		char use = char(i);
		S = temp;
		if (use == 'v') {
			int as = 0;
		}
		int local = 0;
		for (int j = 0; j < S.length()-1; j++) {
			
			for (int k = 0; k < S.length() - local; k++) {
				if (S[k] != use) {
					local++;
					break;
				}
				if (k == S.length() - local - 1) {
					j = 1000;
					ans = min(ans, local);
					break;
				}
			}

			for (int n = 0; n < S.length() - 1; n++) {
				if (S[n] == use || S[n + 1] == use) {
					S[n] = use;
				}
			}
			
		}



	}

	

	cout << ans;


}


Measured memory_bytes: 256
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}


fun solve(out: PrintWriter) {
    val n = readInteger()
    val k = readInteger()
    val xList = readIntegerList()
    var ans = 0
    for (x in xList) {
        ans += Math.min(Math.abs(x) * 2, Math.abs(k - x) * 2)
    }
//    xList.fold(0) { acc, i -> acc + Math.min(Math.abs(i) * 2, Math.abs(k - i) * 2) }
//        .let(::println)
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


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

class Main {

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        int N = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        int[] C = new int[N-1];

        for (int i=0; i<N; i++){
            A[i] = sc.nextInt()-1;
        }
        for (int i=0; i<N; i++){
            B[i] = sc.nextInt();
        }
        for (int i=0; i<N-1; i++){
            C[i] = sc.nextInt();
        }

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

        System.out.println(ans);

    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;
    
        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 21332
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long llong;
const int maxn = 100000;
int A[maxn];
int k,n;

int check(llong P)
{
	int v = 0;
	for(int i = 0;i < k;i++){
		llong sum = 0;
		while(sum + A[v] <= P){
			sum += A[v];
			v++;
			if(v == n)  return n;
		}
	}
	return v;
}

int get_ans()
{
	llong left = 0,right = 100000 * 10000;
	llong mid; 
	while(right - left > 1){
		mid = (right - left) / 2 + left;
		int v = check(mid);
		if(v < n){
			left = mid;
		}
		else{
			right = mid;
		}
	}
	return right;
}
int main()
{
	scanf("%d %d",&n,&k);
	for(int i = 0;i < n;i++){
		scanf("%d",&A[i]);
	}
	int ans = get_ans();
	printf("%d\n",ans);
}


Measured memory_bytes: 3584
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
namespace fastio{
	char in[100000];
	int itr=0,llen=0;
	char get(){
		if(itr==llen)llen=fread(in,1,100000,stdin),itr=0;
		if(llen==0)return EOF;
		return in[itr++];
	}
	char out[100000];
	int itr2=0;
	void put(char c){
		out[itr2++]=c;
		if(itr2==100000){
			fwrite(out,1,100000,stdout);
			itr2=0;
		}
	}
	int clear(){
		fwrite(out,1,itr2,stdout);
		itr2=0;
		return 0;
	}
	int getint(){
    	int ret=0;char ch=get();
		while (ch<'0'||ch>'9'){
			ch=get();if(ch=='-')return -getint();
		}
		while ('0'<=ch&&ch<='9'){
			ret=ret*10-48+ch;
			ch=get();
		}
		return ret;
	}
	string getstr(){
		string ret="";
		char ch=get();
		while(ch==' '||ch=='\n')ch=get();
		while(ch!=' '&&ch!='\n')ret.push_back(ch),ch=get();
		return ret;
	}
	void putstr(string s){
		for(int i=0;i<s.size();i++)put(s[i]);
	}
	void putint(int x){
		if(x<0){
			put('-');
			putint(-x);
			return;
		}
		if(x==0){
			put('0');
			return;
		}
		char c[40];int pos=0;
		while(x){
			c[pos++]='0'+x%10;
			x/=10;
		}
		for(int i=pos-1;i>=0;i--)put(c[i]);
		put(' ');
	}
	void putln(int x){
		if(x<0){
			put('-');
			putint(-x);
			return;
		}
		if(x==0){
			put('0');put('\n');
			return;
		}
		char c[40];int pos=0;
		while(x){
			c[pos++]='0'+x%10;
			x/=10;
		}
		for(int i=pos-1;i>=0;i--)put(c[i]);
		put('\n');
	}
}
using namespace fastio;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n;
int main(){
	n=getint();int i;
	for(i=1;i<=10000;i++){
		if(i*(i+1)/2>=n)break;
	}
	int Not=i*(i+1)/2-n;
	for(int j=1;j<=i;j++){
		if(j!=Not)putln(j);
	}clear();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_N 1000000
#define MAX_M 100
#define min(a,b) a < b ? a : b

void shellSort(int*,int);
void insertionSort(int*,int,int);
void print(int*,int*,int,int);

int cnt;

int main(){
  int N,i,a[MAX_N];

  scanf("%d" ,&N);
  for(i = 0 ; i < N ; i++){
    scanf("%d" ,a+i);
  }
  shellSort(a,N);

  return 0;
}

void shellSort(int a[],int N){
  int G[MAX_M],p = 0,m,i;
  cnt = 0;

  for(m = 1 ; m*3+1 < N ; m = m*3+1){};
  for(; m > 0 ; m /= 3){
    G[p++] = m;
  }

  p = min(p,100);
  for(i = 0 ; i < p ; i++){
    insertionSort(a,N,G[i]);
  }
  print(a,G,N,p);
}

void insertionSort(int a[],int N,int g){
  int i,v,j;

  for(i = g ; i < N ; i++){
    v = a[i]; j = i - g;
    while(j >= 0 && a[j] > v){
      a[j+g] = a[j];
      j -= g;
      cnt++;
    }
    a[j+g] = v;
  }
}

void print(int a[],int G[],int N,int m){
  int i;
  
  printf("%d\n" ,m);
  for(i = 0 ; i < m ; i++){
    if(i != m-1){
      printf("%d " ,G[i]);
    }else{
      printf("%d\n" ,G[i]);
    }
  }
  printf("%d\n" ,cnt);
  for(i = 0 ; i < N ; i++){
    printf("%d\n" ,a[i]);
  }
}

Measured memory_bytes: 4504
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, a[100];
  scanf("%d", &n);
  for(int i = 0; i < n; i++) scanf("%d", &a[i]);

  for(int i = 0; i < n - 1; i++)
  {
    printf("%d ", a[i]);
  }
  printf("%d\n", a[n - 1]);
  

  int key, j;
  for(int i = 1; i < n; i++)
  {
    key = a[i];
    j = i;
    while(j > 0 && a[j - 1] > key)
    {
      a[j] = a[j - 1];
      j--;
    }
    a[j] = key;
    for(int k = 0; k < n - 1; k++)
    {
      printf("%d ", a[k]);
    }
    printf("%d\n", a[n - 1]);
  }

  return 0;

}


Measured memory_bytes: 2104
n,k=map(int, input().split())

su = [0] * n

for i in range(k):
    d=int(input())
    tmp=list(map(int, input().split())) 
#   print(d,tmp)

    for j in range(d):
#       print(tmp[j])
        su[tmp[j]-1] = su[tmp[j]-1] + 1

print(su.count(0))

Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
using namespace std;

map<pair<char,int>,int> m1;
map<char,int> m2;
vector<string> vs;

int rec(string s){
  int res=-1;
  if('0'<=s[0] && s[0]<='9')res=atoi(s.c_str());
  else {
    pair<char,int> p(s[0],rec(s.substr(2,s.length()-3)));
    if(m1.find(p)==m1.end())res=-1;
    else res=m1[p];
  }
  return res;
}

bool check(int index){
  int eq=-1;
  string s=vs[index];
  for(int i=0;i<s.length();i++)if(s[i]=='=')eq=i;
  if(eq==-1)m2[s[0]]=rec(s.substr(2,s.length()-3));
  else {
    int l=rec(s.substr(2,eq-3)),r=rec(s.substr(eq+1,s.length()-eq));
    if(l==-1 || r==-1)return false;
    if(m2[s[0]]<=l)return false;
    m1[mp(s[0],l)]=r;
  }
  return true;
}

int main()
{
  while(1){
    string s;
    vs.clear();
    while(1){
      cin>>s;
      if(s[0]=='.')break;
      vs.push_back(s);
    }

    if(vs.size()==0)break;

    int ans=0;
    m1.clear();
    m2.clear();
    for(int i=0;i<vs.size();i++){
      if(!check(i)){
	ans=i+1;
	break;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1340
#include <bits/stdc++.h>
#define MOD 1000000007
#define inf INT_MAX
#define ll long long int
#define db double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define endl "\n"
#define mp make_pair
#define f first
#define s second
ll power(ll x, ll y, long long int mod = 1000000007){ ll ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
ll modInverse(ll a, ll m){ll m0 = m;ll y = 0, x = 1;if (m == 1) return 0;while (a > 1){ ll q = a / m;ll t = m;m = a % m,a = t;t = y;y = x - q * y;x = t;}if(x < 0) x += m0;return x;}
using namespace std;

int main() {
    fastio;
    ll n, maxw;
    cin >> n >> maxw;
    ll v[n + 1], w[n + 1];
    ll maxVal = 0;
    
    for(int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
        maxVal += v[i];
    }
    
    //cout << maxVal << endl;
    
    ll dp[n + 1][maxVal + 1] = {0};
    ll ans = 0;
    
    for(ll i = 1; i <= n; i++) {
        for(ll j = 1; j <= maxVal; j++) {
            if(i == 1) {
                if(j == v[i]) {
                    dp[i][j] = w[i];
                } else {
                    dp[i][j] = inf;
                }
            } else {
                dp[i][j] = dp[i - 1][j];
                if(j >= v[i])
                    dp[i][j] = min(dp[i][j], w[i] + dp[i - 1][j - v[i]]);
            }
        }
    }
    for(ll i = 0; i <= maxVal; i++) {
        if(dp[n][i] <= maxw) {
            ans = i;
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
const int INF = 1 << 30;

int main() {
    int N = 0;
    cin >> N;
    int K = 0;
    cin >> K;
    vector<int> A(N+1,0);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    vector<int> ans(1+N,INF);
    ans.at(0) = 0;
    for (size_t i = 0; i < N+1; i++)
    {
        for (size_t j = 1; j < K+1; j++)
        {
            if (i+j>N)
            {
                continue;
            }
            
            ans.at(i+j) = min(ans.at(i) + abs(A.at(i+j)-A.at(i)),ans.at(i+j));
        }
        
    }
    cout << ans.at(N-1) << endl;
    

    return 0;
}

Measured memory_bytes: 3964
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println(getFactorial(sc.nextInt()));
	}
	
	public static long getFactorial(int n){
		long factorial = 1;
		for(int i = n; i > 1; i--){
			factorial = factorial * i;
		}
		return factorial;
	}
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

	//素因数分解する
	ll n = N;
	vector<P> vec;//vec[i].first:素因数, second:その素因数の個数
	for(ll i=2; i*i < n; i++){
		ll num = 0;
		while(true){
			if(n%i != 0) break;
			n /= i;
			num++;
		}
		vec.emplace_back(i, num);
	}
	if(n!=1) vec.emplace_back(n, 1);//nが1じゃないならnは素因数となっている(√Nかな)

	// cout << " 素因数分解...:   ";
    // for(int i=0; i<vec.size(); i++){
	// 	for(int j=0; j<vec[i].second; j++){
	// 		cout << vec[i].first << ",  ";
	// 	}
	// }
	// cout << endl;

	ll ans = 0;
	for(int i=0; i<vec.size(); i++){
		ll cnt = 0;
		while(true){
			cnt++;
			if(vec[i].second - cnt < 0) break;
			vec[i].second -= cnt;
			ans++;
		}
	}

	cout << ans << endl;
}


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

public class Main
{
  	int n;
  	long k, tot = 0, mod = (long)1e9+7;
  	long[][] a, I, ans;
  
    Main(Scanner in, PrintWriter out)
    {    	
      n = in.nextInt();
      k = in.nextLong();
      a = new long[n][n];
      for (int i = 0; i < n; i++)
      	for (int j = 0; j < n; j++)
          a[i][j] = in.nextLong();
      I = new long[n][n];
      for (int i = 0; i < n; i++) I[i][i]++;
      ans = exp(a, k);
      for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
        {
          tot += ans[i][j];
          if (tot >= mod) tot -= mod;
        }
      out.println(tot);
    }
  
  	long[][] exp(long[][] a, long b)
    {
      if (b == 0) return I;
      if (b == 1) return a;
      long[][] ans = exp(a, b/2);
      ans = mult(ans, ans);
      if (b %2 == 0) return ans;
      return mult(ans, a);
    }
  
  	long[][] mult(long[][] a, long[][] b)
    {
      long[][] res = new long[n][n];
      for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
          for (int k = 0; k < n; k++)
          {
            long p = a[i][k]*b[k][j];
            p %= mod;
            res[i][j] += p;
            if (res[i][j] >= mod) res[i][j] -= mod;
          }
      return res;
    }
	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new	Main(in, out);
		out.close();
	} 
}


Measured memory_bytes: 28192
from copy import deepcopy


def calc(a, t):
    global ansd, tmp
    flag = deepcopy(a)
    f = False
    for y, b in enumerate(a):
        cnt = 0
        now = tmp - 1
        for x, c in enumerate(b):
            flag[y][x] = False
            if c == now:
                cnt += 1
            else:
                if cnt >= K:
                    ansd += now * cnt * (2 ** t)
                    for z in range(x - cnt, x):
                        flag[y][z] = True
                        f = True
                now = c
                cnt = 1
        if cnt >= K:
            ansd += now * cnt * (2**t)
            for z in range(x - cnt + 1, x + 1):
                flag[y][z] = True
                f = True
    if f:
        a = collapse(a, flag)
        calc(a, t + 1)
    else:
        return


def collapse(m, f):
    global tmp
    ans = [[0] * W for _ in range(H)]
    for x in range(W):
        cnt = H - 1
        for y in range(H)[::-1]:
            if f[y][x]:
                continue
            if m[y][x] < 0:
                continue
            ans[cnt][x] = m[y][x]
            cnt -= 1
            tmp -= 1
    for y in range(H):
        for x in range(W):
            if ans[y][x] == 0:
                ans[y][x] = tmp
                tmp -= 1
    m = ans
    return m


H, W, K = map(int, input().split())
C = [[0] * W for _ in range(H)]
for h in range(H):
    s = input()
    for w, s_ in enumerate(s):
        C[h][w] = int(s_)
ans = 0
for i in range(1, H):
    for j in range(W):
        D = deepcopy(C)
        tmp = -1
        for k in range(1, i+1)[::-1]:
            D[k][j] = D[k-1][j]
        D[0][j] = tmp
        tmp -= 1
        ansd = 0
        calc(D, 0)
        ans = max(ans, ansd)
print(ans)


Measured memory_bytes: 87676
n = int(input())
f = [0]*(n+1)
x = 1
while x*x < n:
    y = 1
    while y*y < n:
        if x*y >= n: continue
        z = 1
        while z*z < n:
            k = x*x + y*y + z*z + x*y + y*z + z*x
            if 1 <= k <= n: f[k] += 1
            z += 1
        y += 1
    x += 1
for i in range(1, n+1): print(f[i])


Measured memory_bytes: 9436
import collections
MOD = 10**9+7
def list_prime(n):
    if n < 2:
        return []
    elif n == 2:
        return [2]
    is_prime = [True for i in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n):
        for j in range(i*i, n+1, i):
            is_prime[j] = False
    prime = []
    for i in range(n+1):
        if is_prime[i]:
            prime.append(i)
    return prime

def cnt_factor(n, p):
    cnt = 0
    pi = p
    while pi <= n:
        cnt += n //pi
        pi *= p
    return cnt

n = int(input())
p_list = list_prime(n)
cnt = 1
for p in p_list:
    cnt = cnt * (cnt_factor(n, p)+1) % MOD
print(cnt)

Measured memory_bytes: 3440
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

class node{
public:
	int sum[11];
	int lazy[11];
	node(){
		for(int i=0;i<10;i++){
			sum[i]=0;
			lazy[i]=0;
		}
	}
};

int n,q;
int f[100001],t[100001];
vector<int> G[100001];
bool used[100001];
node seg[1<<20];
int cnt=0;
int wid=1;

void dfs(int v){
	used[v]=true;
	f[v]=cnt++;
	for(int i=0;i<G[v].size();i++){
		if(!used[G[v][i]]){
			dfs(G[v][i]);
		}
	}
	t[v]=cnt++;
}

int tmp[11];

inline void lazy_evaluate_node(int k){
	memset(tmp,0,sizeof(tmp));
	for(int i=0;i<10;i++){
		tmp[seg[k].lazy[i]]+=seg[k].sum[i];
	}
	for(int i=0;i<10;i++){
		seg[k].sum[i]=tmp[i];
	}
	if(k+1<wid){
		for(int i=0;i<10;i++){
			tmp[i]=seg[k*2+1].lazy[i];
		}
		for(int i=0;i<10;i++){
			seg[k*2+1].lazy[i]=seg[k].lazy[tmp[i]];
		}
		for(int i=0;i<10;i++){
			tmp[i]=seg[k*2+2].lazy[i];
		}
		for(int i=0;i<10;i++){
			seg[k*2+2].lazy[i]=seg[k].lazy[tmp[i]];
		}
	}
	for(int i=0;i<10;i++){
		seg[k].lazy[i]=i;
	}
}

inline void lazy_update_node(int k){
	for(int i=0;i<10;i++){
		seg[k].sum[i]=seg[k*2+1].sum[i]+seg[k*2+2].sum[i];
	}
}

void add(int k,int a){
	k+=wid-1;
	seg[k].sum[0]+=a;
	while(k>0){
		k=(k-1)/2;
		seg[k].sum[0]=seg[k*2+1].sum[0]+seg[k*2+2].sum[0];
	}
}

void update(int f,int t,int a,int b,int k=0,int l=0,int r=wid){
	lazy_evaluate_node(k);
	if(r<=a || b<=l)return;
	if(a<=l && r<=b){
		seg[k].lazy[f]=t;
		lazy_evaluate_node(k);
		return;
	}
	update(f,t,a,b,k*2+1,l,(l+r)/2);
	update(f,t,a,b,k*2+2,(l+r)/2,r);
	lazy_update_node(k);
}

int query(int x,int y,int a,int b,int k=0,int l=0,int r=wid){
	lazy_evaluate_node(k);
	if(r<=a || b<=l)return 0;
	if(a<=l && r<=b){
		int res=0;
		for(int i=x;i<=y;i++){
			res+=seg[k].sum[i];
		}
		return res;
	}
	int vl=query(x,y,a,b,k*2+1,l,(l+r)/2);
	int vr=query(x,y,a,b,k*2+2,(l+r)/2,r);
	lazy_update_node(k);
	return vl+vr;
}

int main(void){
	scanf("%d%d",&n,&q);
	for(int i=0;i<n-1;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
	}
	memset(used,false,sizeof(used));
	dfs(0);
	while(wid<cnt+1)wid*=2;
	for(int i=0;i<wid*2-1;i++){
		for(int j=0;j<10;j++){
			seg[i].sum[j]=0;
		}
	}
	for(int i=0;i<n;i++){
		add(f[i],1);
	}
	for(int i=0;i<q;i++){
		int type,r,x,y;
		scanf("%d%d%d%d",&type,&r,&x,&y);
		if(type==1){
			int res=query(x,y,f[r],t[r]);
			printf("%d\n",res);
		}else{
			update(x,y,f[r],t[r]);
		}
	}
	return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin >> n;
	unordered_map<string, long> ustr;
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		string tmp = "";
		cin >> tmp;
		sort(tmp.begin(), tmp.end());
		if (ustr.find(tmp) == ustr.end()) {
			ustr[tmp] = 1;
		}
		else {
			ustr[tmp]++;
		}
	}
	for(auto it = ustr.begin(); it != ustr.end(); it++) {
		ans += ((it->second)*(it->second-1))/2;
	}
	cout << ans << endl;
	return 0;
}

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


int main(){
	int N,K;
	cin >> N >> K;
	std::vector<int> h(N);
	rep(i,N)cin >> h[i];

	int pos=0;
	std::vector<int> cost(N,INF);
	cost[0] = 0;
	while(pos < N-1){
		for(int i=1; i<=K; i++){
			if(pos+i > N-1) break;
			cost[pos+i] = min(cost[pos]+abs(h[pos+i]-h[pos]), cost[pos+i]);
		}
		pos++;
	}
	cout << cost[N-1] << endl;

	return 0;
}



Measured memory_bytes: 4004
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int L[200];
int main() {
    int i;
    int N;
    scanf("%d",&N);
    for (i = 0; i < 2*N; i++) scanf("%d",&L[i]);
    sort(L,L+2*N);

    int ans = 0;
    for (i = 0; i < N; i++) ans += L[2*i];
    printf("%d\n",ans);

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template <class T> bool chmax(T &a, const T &b) {
  if(a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if(b < a) {
    a = b;
    return 1;
  }
  return 0;
}

class UnionFind {
public:
  UnionFind(int n);
  void unite(int a, int b);
  bool same(int a, int b);
  int find(int a);
  int size(int a);
  vector<int> parent;
};
UnionFind::UnionFind(int n) {
  parent = vector<int>(n, -1);
}
int UnionFind::find(int a) {
  if(parent[a] < 0) return a;
  int p = find(parent[a]);
  parent[a] = p;
  return p;
}
bool UnionFind::same(int a, int b) {
  return find(a) == find(b);
}
void UnionFind::unite(int a, int b) {
  a = find(a);
  b = find(b);
  if(a == b) return;
  parent[a] += parent[b];
  parent[b] = a;
}
int UnionFind::size(int a) {
  a = find(a);
  return -parent[a];
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  vector<ll> list;
  list.push_back((ll)n * (n - 1) / 2);

  UnionFind uf(n);
  ll prev = list[0];
  for(int i = m - 1; i > 0; i--) {
    ll res = prev;
    if(!uf.same(a[i], b[i])) {
      ll s1 = uf.size(a[i]);
      ll s2 = uf.size(b[i]);
      res -= s1 * s2;
      uf.unite(a[i], b[i]);
    }
    list.push_back(res);
    prev = res;
  }
  rrep(i, list.size()) {
    cout << list[i] << endl;
  }
}


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <utility>
using namespace std;
int main()
{
    string s;
    cin >> s;
    string a = "Sunny";
    string b = "Cloudy";
    string c = "Rainy";
    if (s == a)
        cout << b;
    if (s == b)
        cout << c;
    if (s == c)
        cout << a;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

#define MAX_N 200000

int par[MAX_N];
int rnk[MAX_N];
long long int sz[MAX_N];

// 初期化
void init(){
	for(int i = 0; i < MAX_N; i++){
		par[i] = i;
		rnk[i] = 0;
		sz[i] = 1;
	}
}

// x の親を返す
int find(int x){
	if(par[x] == x){
		return x;
	}
	return par[x] = find(par[x]);
}

// x と y を併合する
void unite(int x, int y){
	int x_par = find(x);
	int y_par = find(y);
	if(x_par == y_par){
		return;
	}
	
	if(rnk[x_par] < rnk[y_par]){
		sz[y_par] = sz[x_par] + sz[y_par];
		par[x_par] = y_par;
	}else{
		sz[x_par] = sz[x_par] + sz[y_par];
		par[y_par] = x_par;
		if(rnk[x_par] == rnk[y_par]){
			rnk[x_par]++;
		}
	}
}

// x, y が同じグループか判定
bool same(int x, int y){
	return (find(x) == find(y));
}

int cnt[110000];

int main(){
	int N, M, K;
	cin >> N >> M >> K;
	init();
	for(int i = 0; i < M; i++){
		int A, B;
		cin >> A >> B;
		unite(A, B);
		cnt[A] -= 1;
		cnt[B] -= 1;
	}
	for(int i = 1; i <= N; i++){
		cnt[i] += sz[find(i)];
		cnt[i] -= 1;
	}
	for(int i = 0; i < K; i++){
		int C, D;
		cin >> C >> D;
		if(same(C, D)){
			cnt[C] -= 1;
			cnt[D] -= 1;
		}
	}
	for(int i = 1; i < N; i++){
		cout << cnt[i] << " ";
	}
	cout << cnt[N] << endl;
	return 0;
}

Measured memory_bytes: 4352
import java.util.Scanner;

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

		int n = Integer.parseInt(sc.next());
		int a = 0;
		boolean[] b = new boolean[8];
		int count = 0;

		for (int i = 0; i < n; i++) {
			a = Integer.parseInt(sc.next());

			if (a >= 3200) {
				count++;
			} else if (a >= 2800) {
				b[7] = true;
			} else if (a >= 2400) {
				b[6] = true;
			} else if (a >= 2000) {
				b[5] = true;
			} else if (a >= 1600) {
				b[4] = true;
			} else if (a >= 1200) {
				b[3] = true;
			} else if (a >= 800) {
				b[2] = true;
			} else if (a >= 400) {
				b[1] = true;
			} else {
				b[0] = true;
			}
		}

		int min = 0;
		for (boolean f : b) {
			if (f)
				min++;
		}

		if (min == 0) {
			min = 1;
			count--;
		}

		System.out.println(min + " " + (min + count));

	}

}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
vector<ll> ans;
ll n,m,cur;
string s;
int main(){
	cin>>n>>m;
	cin>>s;
	cur=n;
	while(cur)
	{
		int check=1;
		for(int i=max(0ll,cur-m);i<cur;i++)
			if(s[i]=='0') {check=0;ans.push_back(cur-i);cur=i;break;}	
		if(check){cout<<-1;return 0;}
	}
	reverse(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++){
		cout<<ans[i];
		if(i==ans.size()-1)cout<<endl;
		else cout<<" ";
	}	
	return 0;
}

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

void check(vector<vector<int>> &V){
	long long x = V[0][0],y=V[0][1],z=V[0][2];
	//long long vx = max(0,V[1][0]-V[0][0]),vy = max(0,V[1][1]-V[0][1]),vz = max(0,V[1][2]-V[0][2]);
	long long vx = V[1][0],vy = V[1][1],vz = V[1][2];
	vector<long long> dp(N+1,0);
	/*cout<<x<<','<<y<<','<<z<<endl;
	cout<<vx<<','<<vy<<','<<vz<<endl;*/
	for(int i=1;i<=N;i++){
		long long a = i-x,b=i-y,c=i-z;
		dp[i]=dp[i-1]+1;
		if(a>=0){
			dp[i] = max(dp[i],dp[a]+vx);
		}
		if(b>=0){
			dp[i]=max(dp[i],dp[b]+vy);
		}
		if(c>=0){
			dp[i]=max(dp[i],dp[c]+vz);
		}
	}
	//for(int i=0;i<=N;i++)cout<<dp[i]<<endl;
	N = dp[N];
	
}

int main(){
	
	cin>>N;

	vector<vector<int>> value(2,vector<int>(3));
	
	for(int i=0;i<2;i++){
		for(int j=0;j<3;j++){
			cin>>value[i][j];
		}
	}
	
	check(value);
	swap(value[0],value[1]);
	check(value);
	
	cout<<N<<endl;
	
		
	
	
	
	return 0;
}

Measured memory_bytes: 195584
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
#define MOD ((int)1e9+7)
#define N ((int)1e7+123)
#define M ((int)1e7+20)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

ll ans, n, cont, aux;
ll d[N];
void solve(){
    scanf("%lld", &n);
    ans=1;
    for (ll i = 2; i*i <= n; i++) {
        if(d[i] == 0){
            d[i] = 2;
            //printf("\n%lld\n",i);
            for(ll j = i+i; j <= n;j+=i){
                cont=0;
                aux = j;
                while(aux%i==0){
                    cont++;
                    aux/=i;
                }
                if(d[j]) d[j]*=(cont+1);
                else d[j] = cont+1;
                //printf("(%lld %lld) ",j,d[j]);
            }
        }
        aux = i;
    }
    ans=1;
    for(ll i = 2;i<=n;i++){
        ans+= i * d[i];
        //printf("(%lld %lld)  ", i, d[i]);
        if(d[i] == 0){
            ans+=2*i;
            for(ll j = i+i;j<=n;j+=i)d[j]*=2;//, printf("\n %lld",j);
            //printf("\n");
        };
    }
    printf("%lld\n", ans);
}

int main(){
    ios_base::sync_with_stdio(0);
    int t = 1; //scanf("%d",&t);
    for(int caso=1;caso<=t;caso++){
        solve();
    }
}

Measured memory_bytes: 81960
N = gets.chomp.to_i

if N.even?
  # p [N / 4, N * N * (N / 2) / (N * N + N * N / 2 + N * N / 2)]
  puts "#{N} #{N} #{N / 2}"
else
  (1..3500).each do |h|
    (1..3500).each do |n|
      if h.even? || n.even? then
        x = N * h * n
        y = (4 * h * n - N * n - N * h)
        if y > 0 && x % y == 0
          # p [N / 4, h * n * (x / y) / (h * n + n * x / y + h * x / y)]
          puts "#{h} #{n} #{x / y}"
          exit
        end
      end
    end
  end    
end



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

int R;

int main()
{
	cin>>R;
	
	if(R<1200) cout<<"ABC\n";
	
	else if(R>=1200 && R<2800) cout<<"ARC\n";
	
	else if(R>=2800) cout<<"AGC\n";
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n,d,i=0;
	cin>>n>>d;
	while(n--)
	{
		double a,b;
		cin>>a>>b;
		double x = (a*a)+(b*b);
		double y = sqrt(x);
		ll ans = ceil(y);
		if(ans<=d)
		{
			i++;
		}
	}
	cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 3816
{-# LANGUAGE BangPatterns, MultiWayIf #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Int
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> VU.Vector Int -> Int
solve !n !an = fst $ VU.head $ V.last dp
 where
  dp :: V.Vector (VU.Vector (Int, Int))
  dp = V.constructN
    n
    (\(!vec) ->
      let i = V.length vec
      in  VU.map
              (\(!j) -> if i == 0
                then let z = an VU.! j in (0, z)
                else minimum
                  [ let (c1, s1) = vec V.! k VU.! j
                        (c2, s2) = vec V.! (i - k - 1) VU.! (j + k + 1)
                        s        = s1 + s2
                    in  (c1 + c2 + s, s)
                  | k <- [0 .. i - 1]
                  ]
              )
            $ VU.fromList [0 .. n - i - 1]
    )

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  n  <- (\vec -> (vec VU.! 0)) . VU.unfoldrN 1 readInt <$> B.getLine
  an <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n an


Measured memory_bytes: 7804
#include<iostream>

using namespace std;

#define long long long

long n;
long a[100001], b[100001], c[100001], dp[100001][4];

long cal(int idx, int val) {
    if (idx > n) return 0;
    if (dp[idx][val] != -1) return dp[idx][val];
    dp[idx][val] = 0;

    if (val == 0) dp[idx][val] = max(cal(idx + 1, 1) + a[idx], max(cal(idx + 1, 2) + b[idx], cal(idx+1,3) + c[idx]));
    if (val == 1) dp[idx][val] = max(cal(idx + 1, 2) + b[idx], cal(idx + 1, 3) + c[idx]);
    if (val == 2) dp[idx][val] = max(cal(idx + 1, 1) + a[idx], cal(idx + 1, 3) + c[idx]);
    if (val == 3) dp[idx][val] = max(cal(idx + 1, 1) + a[idx], cal(idx + 1, 2) + b[idx]);
    return dp[idx][val];
}

void FastInOut() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
}

void Input() {
    cin >> n;
    for (int i = 1; i <= n; i ++) cin >> a[i] >> b[i] >> c[i];
    for (int i = 1; i <= n; i ++)
        for (int j = 0; j <= 3; j ++) dp[i][j] = -1;
}

void Solve() {
    cout << cal(1,0);
}

int main() {
    FastInOut();
    Input();
    Solve();
}


Measured memory_bytes: 10368
#include <stdio.h>
int main(){
    long long r,d,x,buf,i;
    scanf("%lld%lld%lld",&r,&d,&x);
    for(i=0;i<10;i++){
        buf=r*x-d;
        printf("%lld\n",buf);
        x=buf;
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL

struct Edge {
	int from, to;
	ll w;
};
typedef vector<vector<Edge>> Graph;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}

ll gettugibaisu(ll from, ll k) { 

	ll ret = ((from + k - 1) / k) * k;

	return ret;
}

ll getmaebaisu(ll to, ll k) { 

	ll ret = (to / k) * k;

	return ret;
}

signed main(void) {

	int k;
	cin >> k;
	vector<ll> a(k);

	REP(i, k) {
		cin >> a[i];
	}

	ll l = 1, r = LLONG_MAX/2-1; // l muri

	auto sim = [&](ll n) {

		REP(i, k) {
			n = n - n % a[i];
		}

		return n;
	};

	if (sim(r) == 0) {
		cout << -1 << endl;
		return 0;
	}

	while (r - l > 1) {
		ll mid = (r + l) / 2;

		if (sim(mid) < 2) {
			l = mid;
		}
		else
		{
			r = mid;
		}
	}

	if(sim(l + 1) != 2) {
		cout << -1 << endl;
		return 0;
	}

		printf("%lld ", l + 1);
	l = 1, r = LLONG_MAX / 2 - 1; // l muri

	while (r - l > 1) {
		ll mid = (r + l) / 2;

		if (sim(mid) > 2) {
			r = mid;
		}
		else
		{
			l = mid;
		}
	}

	printf("%lld\n", l);

	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
  //  https://atcoder.jp/contests/dp/tasks/dp_e
  // sum  of value 1000 x 100 = 100 000 
  // x 100 -> 10 trieu

  ll N, W;
  cin >> N >> W;

  vector<ll> w(N+1), v(N+1);

  for (ll i=1; i<=N; i++) {
    cin >> w[i] >> v[i];
  }

  ll max_value = N * *max_element( v.begin(), v.end() );

  ll INF = 1e18;

  vector< vector<ll> > F ( N+1 );  // i, j, i = 1.. N, j, 0 ---> 100 000
  F[0] = vector<ll>(max_value+1, INF);
  F[0][0] = 0;
  for (ll i = 1; i<= N; i++ ) {
    F[i] = vector<ll>(max_value+1, INF);
    F[i][0] = 0;
    for (auto tv = 0; tv <= max_value; tv++) {
      if (tv < v[i]) {
        F[i][tv] = F[i-1] [tv];
      } else {
        F[i][tv] =  min(
          F[i-1] [tv],
          F[i-1] [tv- v[i]] + w[i]
        );
      }

      // cout << i << "  " << tv  << " " << F[i][tv] << endl;
    }
  }

  for (auto i=max_value; i > 0; i--) {
    if( F[N][i] <=  W) {
      cout << i << endl;
      return 0;
    }

  }
  return 0;
}



Measured memory_bytes: 79488