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

using namespace std;
#define popcnt(a) __builtin_popcount(a)
#define GCD(a,b) __gcd(a,b)
#define IO() assert(freopen("in.in", "rt", stdin)), assert(freopen("out.out", "wt", stdout))
#define FastIO() ios::sync_with_stdio(false),cin.tie(0);
#define clr(arr,val) memset(arr,val,sizeof(arr))
#define INF 0x9f9f9f9f9f9f9f9f
#ifdef _LOCAL_DEFINE
template<typename...T>
void debug(T&... args) 
{
  ((cerr<<args<<" "),...);
  cerr<<endl;
}
#endif

typedef long long LL;
typedef pair<int,int> pi;
const LL MOD = 1e9 + 7;
const int N = 1e6 + 9, M = 1e7, OO = 0x7f7f7f7f;

const double EPS = 1e-10,PI=acos(-1.0);

//Number Theory
inline bool dCMP(const long double &a, const long double &b) { return fabsl(a - b) < EPS;}

//Geometry 
inline double MintoDeg(double min){return min/60;}
inline double to_Radian(double deg){return deg*PI/180.0;}
inline double to_Degree(double radian){if(radian<0) radian+=2*PI; return radian*180/PI ;}
inline double fixAngle(double A){return A>1 ? 1 : (A<-1 ? -1 : A);}
struct point { 
  double x, y;
  point() { x = y = 0.0; }
  point(double _x, double _y) : x(_x), y(_y) {}
  bool operator < (point other) const { // override less than operator
  if (fabs(x - other.x) > EPS) return x < other.x;
  
  return y < other.y; 
  }
  bool operator == (point other) const {
  return (fabs(x - other.x) < EPS && (fabs(y - other.y) < EPS)); 
  }   
};
LL power(LL x, LL p, LL m){
  LL res = 1;
  while(p){
    if(p&1)	res = (res%m * x%m)%m;
    x = (x%m * x%m)%m;
    p >>= 1;
  }
  return res;
}

int main()
{
  LL x;
  scanf("%lld",&x);
  LL res=x/11,rem=x%11;
  if(rem==0) rem=0;
  else if(rem>=7) rem=2;
  else rem=1;
  printf("%lld\n",(res*2)+rem);

  #ifdef _LOCAL_DEFINE
    cerr << clock()*1.0/CLOCKS_PER_SEC<<endl;
  #endif
    
  return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))

maxP = [p[0]]
for i in range(1, n):
    maxP.append(min(maxP[i - 1], p[i]))


ans = 0
for i in range(n):
    if p[i] <= maxP[i]:
        ans += 1

print(ans)

Measured memory_bytes: 85840
#include <stdio.h>
int main()
{
	int n, i, m;
	while(scanf("%d", &n)!=EOF)
	{
		int N = n;
		int sum = 0;
		for(i = 1 ; i <= 10 ; i++)
		{
			m = n % 10;
			n = n / 10;
			sum = sum + m;
			if(n < 0)break;
		}
		if(N % sum == 0)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
// Born Sinner
// old but im not that old
// fuck all you hoes get a grip
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next(){
            while(st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt(){
            return Integer.parseInt(next());
        }
        long nextLong(){
            return Long.parseLong(next());
        }
        double nextDouble(){
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try{
                str = br.readLine();
            } catch (Exception e){
                e.printStackTrace();
            }
            return str;
        }
    }
    static int modPower(int x, int y, int mod){
        int res = 1;
        x %= mod;
        if(x==0) return 0;
        while(y>0){
            if(y%2==1){
                res = (res*x)%mod;
            }
            y = y>>1;
            x = (x*x)%mod;
        }
        return res;
    }
    static class pair<T1, T2>{
        T1 first;
        T2 second;
        pair(T1 first, T2 second){
            this.first = first;
            this.second = second;
        }
    }
    
    public static void main (String[] args) throws java.lang.Exception
    {
        FastReader in = new FastReader();
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i =0 ;i < n; i++){
            a[i] = in.nextInt();
        }
        int ans = Integer.MAX_VALUE;
        for(int i = 0; i < 101; i++){
            int cur = 0;
            for(int j = 0; j < n; j++){
                cur += (i-a[j])*(i-a[j]);
            }
            ans = Math.min(ans,cur);
        }
        System.out.println(ans);
    }
}


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

namespace Practice
{
    class Program
    {

        static void Main(string[] args)
        {
            //SolveA(args);
            SolveB(args);
            //SolveC(args);
        }


        static void SolveA(string[] args)
        {
            string sz = (Console.ReadLine());
            int num = 0;
            for(int i=0;i<sz.Length;++i)
            {
                char c = sz[i];
                if( c == '+')
                {
                    num++;
                }else
                {
                    num--;
                }
            }
            Console.WriteLine(num);
        }
        static void SolveB(string[] args)
        {
            string sz = Console.ReadLine();
            long n = long.Parse(sz);
            int sn = 0;
            for (int i = 0; i < sz.Length; ++i)
            {
                int tmp = int.Parse(sz[i].ToString());
                sn += tmp;
            }
            if( n % sn == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
        static void SolveC(string[] args)
        {
            string sz = Console.ReadLine();
            long n = long.Parse(sz);
            int sn = 0;
            for (int i = 0; i < sz.Length; ++i)
            {
                int tmp = int.Parse(sz[i].ToString());
                sn += tmp;
            }
            if (n % sn == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }


    }

}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    int a,b,c;
    cin >> a >> b >> c;
    if (a==b&&b==c||a!=b&&b!=c&&a!=c) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=[A[0]]
n=0
for i in range(1,N):
    B.append(A[i]-B[-1])
B.append(A[0]-B[-1])
#print(B)
X=(B[0]-B[-1])//2
Y=[X]
Z=[X*2]
for i in range(N-1):
    Y.append(A[i]-Y[i])
    Z.append(Y[-1]*2)
print(*Z)


Measured memory_bytes: 76900
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		String s = sc.next();
		
		StringBuilder sb = new StringBuilder();
		
		for(char c : s.toCharArray()) {
			if(c == '0') {
				sb.append(0);
			}else if(c == '1'){
				sb.append(1);
			}else{
				if(sb.length() != 0) {
					sb.deleteCharAt(sb.length()-1);
				}
			}
		}
		
		out.println(sb.toString());
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 23252
n,k=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr)
acum=[0]
for i in range(n):
  acum.append(acum[-1]+arr[i])
mod=10**9+7
ans=0
if k==1:
  print(ans)
elif k==2:
  for i in range(1,n):
    ans+=acum[n]-acum[i]-arr[i-1]*(n-i)
    ans%=mod
  print(ans)
else:
  facts=[1,1]
  for i in range(2,n-1):
    facts.append(facts[-1]*i)
    facts[-1]%=mod
  for i in range(k-1,n):
    ways=facts[i-1]*pow(facts[k-2],mod-2,mod)*pow(facts[(i-1)-(k-2)],mod-2,mod)
    ways%=mod
    ans+=(acum[n]-acum[i]-acum[n-i])*ways
    ans%=mod
  print(ans)

Measured memory_bytes: 17368
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long LL;

const int N = 200005;

int n, s[N];

int main() {
	scanf("%d", &n);
	for (int i = 2, p; i <= n; i++) {
		scanf("%d", &p);
		s[p]++;
	}
	for (int i = 1; i <= n; i++) printf("%d\n", s[i]);
	return 0;
}

Measured memory_bytes: 3884
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  string s,t;cin>>s>>t;
  vector<vector<int>> dp(s.size()+1,vector<int>(t.size()+1,0));
  rep(i,s.size()){
    rep(j,t.size()){
      if(s[i] == t[j])dp[i+1][j+1] = dp[i][j]+1;
      else dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
    }
  }

  int len = dp[s.size()][t.size()];
  int i = s.size();
  int j = t.size();
  string ans(len,' ');

  while(len>0){
    if(s[i-1] == t[j-1]){
      ans[--len] = s[i-1];
      i--;
      j--;
    }else if(i&&dp[i][j] == dp[i-1][j]){
      i--;
    }else{
      j--;
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 38432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
  string S;
  cin >> S;
  int ans = 0;
  if(S == "MON") ans = 6;
  if(S == "TUE") ans = 5;
  if(S == "WED") ans = 4;
  if(S == "THU") ans = 3;
  if(S == "FRI") ans = 2;
  if(S == "SAT") ans = 1;
  if(S == "SUN") ans = 7;
  cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main() {
	int n;
	cin>>n;
	std::vector<int> a;
	int t;
	int c=1;

	for(int i=0;i<n;i++){
		scanf("%d",&t);
		a.push_back(t);
		if(a[i]==c){
			c++;
		}
	}
	if(c==1){
		printf("-1\n");
	}else{
		printf("%d\n", n-(c-1));
	}
	
	return 0;
}

Measured memory_bytes: 1400
def countTriangles( A): 
    n = len(A); 
    A.sort();  
    count = 0; 
    for i in range(n - 1, 0, -1): 
        l = 0; 
        r = i - 1; 
        while(l < r): 
            if(A[l] + A[r] > A[i]):
                count += (r - l);
                r -= 1;  
            else:
                l += 1;  
    print(count); 
  
n=int(input())
l=list(map(int,input().split()))  
countTriangles(l)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main() {
  int	A,B;
  int	C,D;
  int	left_total ;
  int	right_total ;
  
  cin >> A >> B >> C >> D;

  left_total = A+B;
  right_total = C+D;
  if(left_total > right_total){
    cout << "Left" << endl;
  }
  else if(left_total < right_total){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}
 


Measured memory_bytes: 256
A,B,C,X = map(int,open(0).read().split())

ans = 0
for a in range(0, A+1):
    for b in range(0, B+1):
        for c in range(0, C+1):
            if (500*a)+(100*b)+(50*c) == X:
                ans += 1

print(ans)

Measured memory_bytes: 39536
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin >> s;
    for(int i = 1;i < s.size();i++){
        if(s[i - 1] == s[i]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 256
use proconio::*;
use std::cmp::max;

fn main() {
    input! {
        n: usize,
        m: usize,
        k: i64,
        mut a: [i64; n],
        mut b: [i64; m],
    };
    a.insert(0, 0);

    let mut acc = b.iter().sum::<i64>();
    let mut j = m;
    let mut ans = 0;

    for i in 0..a.len() {
        acc += a[i];
        while acc > k && j > 0 {
            j -= 1;
            acc -= b[j];
        }

        if acc > k {
            break;
        }

        ans = max(ans, j + i);
    }

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


Measured memory_bytes: 9488
N = input()
s = []
for i in range(int(N)):
  s.append(input())
M = input()
t = []
for i in range(int(M)):
  t.append(input())
  
strdict = dict()
strset = set()
strset.add('')
strdict['']=0

for str in s:
  if str in strset:
    strdict[str]+=1
  else:
    strset.add(str)
    strdict[str]=1
for str in t:
  if str in strset:
    strdict[str]-=1
  else:
    strset.add(str)
    strdict[str]=-1

maxval=0
for str in strset:
  if maxval < strdict[str]:
    maxval=strdict[str]
print(maxval)

Measured memory_bytes: 9156
//Payment 

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n;cin>>n;
    rep(i,0,11){
        if(n<=i*1000){
            cout<<1000*i-n<<nnn;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

using data = pair<ll, vector<ll>>;

int main()
{
    ll x, y, z, k; cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
    sort(rALL(a)), sort(rALL(b)), sort(rALL(c));

    priority_queue<data> q;
    set<data> se;
    q.push(data(a[0] + b[0] + c[0], vector<ll>({0, 0, 0})));
    while(k > 0)
    {
        auto cur = q.top(); q.pop();
        cout << cur.first << endl;
        ll ia = cur.second[0], ib = cur.second[1], ic = cur.second[2];

        data tmp;
        if (ia + 1 < a.size())
        {
            tmp = data(a[ia + 1] + b[ib] + c[ic], vector<ll>({ia + 1, ib, ic}));
            if (!se.count(tmp))
            {
                se.insert(tmp);
                q.push(tmp);
            }
        }
        if (ib + 1 < b.size())
        {
            tmp = data(a[ia] + b[ib + 1] + c[ic], vector<ll>({ia, ib + 1, ic}));
            if (!se.count(tmp))
            {
                se.insert(tmp);
                q.push(tmp);
            }
        }
        if (ic + 1 < c.size())
        {
            tmp = data(a[ia] + b[ib] + c[ic + 1], vector<ll>({ia, ib, ic + 1}));
            if (!se.count(tmp))
            {
                se.insert(tmp);
                q.push(tmp);
            }
        }
        k--;
    }
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

  static long x, k, d, ans;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    x = Long.parseLong(in[0]);
    k = Long.parseLong(in[1]);
    d = Long.parseLong(in[2]);

    br.close();

    if (in[1].length() + in[2].length() > 17) {
      long p = x % d;
      boolean is_even = ((x / d) % 2 == 0);
      if ((k - x / d) % 2 == 0) {
        ans = p;
      } else {
        if (p < 0) {
          ans = p + d;
        } else {
          ans = p - d;
        }
      }
    } else if (Math.abs(x) <= k * d) {
      long p = x % d;
      boolean is_even = ((x / d) % 2 == 0);
      if ((k - x / d) % 2 == 0) {
        ans = p;
      } else {
        if (p < 0) {
          ans = p + d;
        } else {
          ans = p - d;
        }
      }
    } else {
      ans = Math.abs(x) - k * d;
    }

    out.println(Math.abs(ans));

    out.flush();
  }
}


Measured memory_bytes: 32856
#include<bits/stdc++.h>
using namespace std;
double p[3000];
vector<vector<double>> dp(3000,vector<double>(3000,0.0));
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>p[i];
    dp[0][0] = 1.0;
    for(int i=1;i<=n;i++)dp[i][0]=dp[i-1][0]*(1.0-p[i-1]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=i;j++)
            dp[i][j] = dp[i-1][j]*(1.0-p[i-1])+dp[i-1][j-1]*(p[i-1]);
    double ans = 0.0;
    for(int i=((n/2)+1);i<=n;i++)
        ans+=dp[n][i];
    cout<<fixed<<setprecision(12)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 70784
import java.util.*;
 
public class Main{
  public static void main (String[] args){
   Scanner sc = new Scanner(System.in);
    
   int a = sc.nextInt();
   String s = sc.next();
    
   if(a < 3200){
   	s = "red";
   }
    
   System.out.println(s);
  }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int>>

using namespace std;

int main(){
    int n, tmp;
    cin >> n;
    vi a(n);
    int f = 0;
    int s = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(f < a[i]){
            s = f;
            f = a[i];
        }else if(s < a[i]){
            s = a[i];
        }
    }
    for(int i = 0; i < n; i++){
        if(f == a[i]) cout << s << endl;
        else cout << f << endl;
    }
    return 0;
}

Measured memory_bytes: 2432
n = gets.to_i
board = 2.times.map { gets.split.map(&:to_i) }

(0..1).each do |i|
  sum = 0
  (0..n-1).each do |j|
    board[i][j] += sum
    sum = board[i][j]
  end
end
max_res = -1
(0..n-1).each do |i|
  res = board[0][i] + board[1][n-1]
  res -= board[1][i-1] if i > 0
  max_res = res if res > max_res
end
puts max_res

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

using namespace std;

long long k, a, b, ans = 1, mi;

int main() {
	scanf("%lld%lld%lld", &k, &a, &b);
	mi = min(a - 1, k);
	k -= mi;
	ans += mi;
	if (k) {
		if (k & 1) {
			k--;
			ans++;
		}
		ans += max(2LL, b - a) * (k / 2);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		
		int sum = 0;
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
				for (int j = 2; ; j *= 2) {
					if (a[i] % j == 0) {
						sum++;
					} else {
						break;
					}
				}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 34252
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <iomanip>
int main()
{
	int K, N;
	std::cin >> K >> N;
	std::vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> A[i];
	}
	int min_dist = K;
	for (int i = 0; i < N; ++i) {
		int	dist1 = (i==N-1)?(A[N-1]-A[0]):(K - A[i + 1] + A[i]);
		int	dist2 = (i == 0) ? (A[N - 1]-A[0]) : (K - A[i] + A[i - 1]);
		min_dist = std::min<int>(min_dist, dist1);
		min_dist = std::min<int>(min_dist, dist2);
	}
	std::cout << min_dist << std::endl;
	return 0;
}

Measured memory_bytes: 4044
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll a, b, c, d;

int main()
{
    cin>>a>>b>>c>>d;
    while(1)
    {
        c -= b;
        if(c <= 0)
        {
            printf("Yes\n");
            return 0;
        }
        a -= d;
        if(a <= 0)
        {
            printf("No\n");
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 50000000000000000;
typedef std::pair<int,int> P;
struct edge {int to,cost;};

    ll N,H,W;
    ll A[10010];
    int ans[101][101];
int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>H>>W>>N;
    REP(i,N)cin>>A[i];
    int cnt=0;
    REP(i,H)REP(j,W){

        if(i%2){
            ans[i][W-j-1]=cnt+1;
        }else{
            ans[i][j]=cnt+1;
        }

        A[cnt]--;
        if(A[cnt]==0)cnt++;

    }
    REP(i,H){
        REP(j,W){
            cout<<ans[i][j];
            if(W-1==j)cout<<"\n";
            else cout<<" ";
        }
    }
    return 0;
}


Measured memory_bytes: 384
s = input()
N = s.count("N")
W = s.count("W")
S = s.count("S")
E = s.count("E")
flag = -1
if (S > 0 and N > 0) or (S == 0 and N == 0) :
    if (E > 0 and W > 0) or (E == 0 and W == 0) :
        flag = 1
if flag == 1 :
    print("Yes")
else :
    print("No")


Measured memory_bytes: 9016
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

std::vector<int> pre(1001*1001, -1);
bool flag = true;
//-------------------------------------------------------------------
int MAX_V = 1001*1001;
vvi G = vv(MAX_V, 0, 0, int);
vvi rG = vv(MAX_V, 0, 0, int);
vector<bool> used(MAX_V);
vector<int> cmp(MAX_V);
vector<int> vs;
void add_edge(int from, int to){ G[from].push_back(to), rG[to].push_back(from);}
void dfs(int v){
  used[v] = true;
  for(int i=0;i<G[v].size();i++) if(!used[G[v][i]]) dfs(G[v][i]);
  vs.push_back(v);
}
void rdfs(int v, int k){
  used[v] = true;
  cmp[v] = k;
  for(int i=0;i<rG[v].size();i++) {
    if(!used[rG[v][i]]) {
      rdfs(rG[v][i], k);
      flag = false;
    }
  }
}
int scc(int V){
  for(int i=0;i<MAX_V;i++) used[i] = false;
  vs.clear();
  for(int i=0;i<=V;i++) if(!used[i]) dfs(i);
  for(int i=0;i<MAX_V;i++) used[i] = false;
  int k = 0;
  for(int i=vs.size()-1;i>=0;i--) if(!used[vs[i]]) rdfs(vs[i], k++);
  return k;
}
std::vector<int> mpath(1001*1001, -1);

int f(int now){
  if(mpath[now]!=-1) return mpath[now];
  int d = 0;
  for(int i=0;i<G[now].size();i++) d = max(d, f(G[now][i]));
  d++;
  mpath[now] = d;
  return d;
}
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  int N;
  scanf("%d", &N);
  vvi A = vv(N+1, N, 0, int);
  vector<int> nyu(1001*1001, 1);
  for(int i=1;i<=N;i++) for(int j=1;j<=N-1;j++) scanf("%d", &A[i][j]);
  for(int i=1;i<=N;i++) {
    for(int j=1;j<=N-2;j++) {
      add_edge(min(i,A[i][j])*1001+max(i,A[i][j]), min(i,A[i][j+1])*1001+max(i,A[i][j+1]));
      nyu[min(i,A[i][j+1])*1001+max(i,A[i][j+1])] = 0;
    }
  }
  scc(1001*1001);
  if(!flag){
    printf("-1\n");
    return 0;
  }
  int ans = 0;
  for(int i=0;i<1001*1001;i++) if(nyu[i]==1) ans = max(f(i), ans);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 104436
#include<stdio.h>

#define N 20
#define Q 200

int judge(int,int);

int A[N],n;

int main(){
  int i;
  int q;
  int m;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(judge(0,m)==1) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int judge(int i,int m){
  int r;
  if(m==0) return 1;
  if(i>=n) return 0;
  return judge(i+1,m) || judge(i+1,m-A[i]);
}



Measured memory_bytes: 2084
//include
//------------------------------------------
#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 <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	for (int i = 1; i < 6; i++) {
		int v; cin >> v;
		if (v == 0) {
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
char s[110],a[110],b,i,t;
main(){
while(fgets(s,110,stdin)){
if(s[1]=='\n'&&s[0]==46)break;
for(t=1,b=0,i=0;s[i]&&t;++i){
if(s[i]==40||s[i]==91) a[b++]=s[i];
else if(s[i]==41||s[i]==93) {
if(!b){t=0;break;}
if((s[i]==41&&a[b-1]==40)||(s[i]==93&&a[b-1]==91)) --b;
else t=0;
}
}
puts(((t&&!b)?1:0)?"yes":"no");
}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5+5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


int k;

void solve()
{
    cin >> k; string s = "ACL";
    while (k--) cout << s;
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

main()
{
  string now; cin >> now;
  string before;

  // now中の"ABC"を元に合った文字に入れ替える
  while(now != "ABC"){
    before = now; // 変更前を記録

    vi abcpos; // "ABC"がある位置を記録
    rep(i,sz(now) - 2) if(now.substr(i,3) == "ABC") abcpos.pb(i);
    dump(abcpos);

    vi abcused(3); // A,B,Cがabcpos以外で使われているか判定
    rep(i,sz(now)){
      if(i < i_cond - 2 and now.substr(i,3) == "ABC") i += 2;
      else abcused[now[i] - 'A'] = 1;
    }
    dump(abcused);
    if(SUM(abcused) != 2) break; // 2種類でなければおかしい
    string lostchar; // 残りの1種類を格納
    rep(i,3) if(abcused[i] == 0) lostchar = char('A' + i);
    dump(lostchar);

    // 後ろから"ABC"を消して代わりにlostcharを挿入
    reverse(all(abcpos));
    rep(i,sz(abcpos)){
      now.erase(abcpos[i],3);
      now.insert(abcpos[i],lostchar);
    }
    
    if(before == now) break; // 変わっていなければおかしい
    dump(now);
  }

  if(now == "ABC") cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 3188
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
// Original: https://img.atcoder.jp/practice2/ac-library.zip

/*
 * Return sum of floor((A*i+B)/M) from i = 0 ... N-1
 */
long long floor_sum(long long n, long long m, long long a, long long b) {
  long long ans = 0;
  if (a >= m) {
    ans += (n - 1) * n * (a / m) / 2;
    a %= m;
  }
  if (b >= m) {
    ans += n * (b / m);
    b %= m;
  }

  long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
  if (y_max == 0) return ans;
  ans += (n - (x_max + a - 1) / a) * y_max;
  ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
  return ans;
}


class CFloorSum {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int t; cin >> t;
      while(t--) {
        ll n, m, a, b; cin >> n >> m >> a >> b;
        cout << floor_sum(n, m, a, b) << '\n';
      }
    }
};

signed main() {
  CFloorSum solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
 vector<int> S = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 int N;
  cin >> N;
  cout << S.at(N - 1) << endl;
}

Measured memory_bytes: 256
n,*a=`dd`.split.map &:to_i;a.sort!;r=0;b=[0]+n.times.map{|j|a[j]*(-1)**j%24};s=24;n.times{|j|(j+1..n).each{|k|s=[s,(b[j]-b[k])%24,(b[k]-b[j])%24].min}};r=[r,s].max;p r

Measured memory_bytes: 3960
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int x;
    cin>>x;
    int ans=1;
    repi(i,1,x){
        repi(j,2,x){
            int p=pow(i,j);
            if(p>x) break;
            ans=max(ans,p);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 4060
a = list(map(int, input().split()))
if a[0] % a[1] == 0:
    print(-1)
else:
    b = 1
    while b <= a[1]:
        c = a[0] * b
        if c % a[1] != 0 and c <= 10 ** 18:
            print(c)
            break
        else:
            b = b + 1
    if b == a[1] + 1 or c > 10 ** 18:
        print(-1)

Measured memory_bytes: 3064
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    a = LI()
    a.sort()
    x = list(set(a))
    if len(x) > 3:
        print("No")
    elif len(x) == 3:
        x1 = bisect_right(a, x[0]) - bisect_left(a, x[0])
        x2 = bisect_right(a, x[1]) - bisect_left(a, x[1])
        x3 = bisect_right(a, x[2]) - bisect_left(a, x[2])
        if ((x[0] ^ x[1] ^ x[2]) == 0) and (x1 == x2 == x3):
            print("Yes")
        else:
            print("No")
    elif len(x) == 2:
        x1 = bisect_right(a, 0) - bisect_left(a, 0)
        x2 = bisect_right(a, x[1]) - bisect_left(a, x[1])
        if x1 * 2 == x2:
            print("Yes")
        else:
            print("No")
    elif len(x) == 1:
        if x[0] == 0:
            print("Yes")
        else:
            print("No")
    return

#B
def B():
    n, m = LI()
    if m % 2:
        print(-1)
        return
    edg = [[] for _ in range(n)]
    ins = defaultdict(int)
    c = defaultdict(int)
    for _ in range(m):
        a, b = LI_()
        edg[a].append(b)
        edg[b].append(a)
        ins[a] += 1
        ins[b] += 1
    dag = [[] for _ in range(n)]
    q = deque()
    q.append((0, -1))
    for i in edg[0]:
        q.append((i, 0))
    while q:
        now, per = q.pop()
        if per == -1:
            continue
        if c[now]:
            pass
        
    for d in dag:
        if len(d) % 2:
            print(-1)
            return
    for num, d in enumerate(dag):
        for x in d:
            print(num + 1, x + 1)
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 58992
#include <iostream>
#include <vector>
using namespace std;
int INF = 100000000;
int main(){
  int n, M = 1000000;
  vector<int> A(M,INF), A_odd(M,INF);
  int t = 1, k = 3;
  A[0] = 0;
  A_odd[0] = 0;
  while(t < 1000000){
    for(int k = 0; k+t < M; ++k){
      A[k+t] = min(A[k]+1,A[k+t]);
      if(t%2) A_odd[k+t] = min(A_odd[k]+1,A_odd[k+t]);
    }
    ++k;
    t *= k;
    t /= (k-3);
  }
  while(cin >> n, n){
    cout << A[n] << " " << A_odd[n] << endl;
  }
  return 0;
}


Measured memory_bytes: 10532
#include <iostream>
#include <vector>

int main()
{
    const int mod = 1000000007;
    long long n, k;
    std::cin >> n >> k;

    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    long long p = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] > a[j]) {
                p++;
                p %= mod;
            }
        }
    }

    long long q = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[i] > a[j]) {
                q++;
                q %= mod;
            }
        }
    }

    long long p_ans = p * k % mod;
    long long q_ans = k * (k - 1) / 2 % mod;
    q_ans *= q;
    q_ans %= mod;

    long long ans = p_ans + q_ans;
    ans %= mod;

    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
n = gets.to_i
ary = []

[3,5,7].repeated_permutation(3) do |bits|
  if bits.uniq.size == 3
    ary << bits.join("").to_i
  end
end
[3,5,7].repeated_permutation(4) do |bits|
  if bits.uniq.size == 3
    ary << bits.join("").to_i
  end
end
[3,5,7].repeated_permutation(5) do |bits|
  if bits.uniq.size == 3
    ary << bits.join("").to_i
  end
end
[3,5,7].repeated_permutation(6) do |bits|
  if bits.uniq.size == 3
    ary << bits.join("").to_i
  end
end
[3,5,7].repeated_permutation(7) do |bits|
  if bits.uniq.size == 3
    ary << bits.join("").to_i
  end
end
[3,5,7].repeated_permutation(8) do |bits|
  if bits.uniq.size == 3
    ary << bits.join("").to_i
  end
end
[3,5,7].repeated_permutation(9) do |bits|
  if bits.uniq.size == 3
    ary << bits.join("").to_i
  end
end

arys = ary.sort
puts arys.count{|x| x<=n}

Measured memory_bytes: 14964
import scala.io.{StdIn => in}

object Main extends App {
  val Array(r, d, x) = in.readLine.split(" ").map(_.toLong)

  def f(init:Long) = {
    var holder = init
    () => {
      val cur = holder
      holder = holder * r - d
      cur
    }
  }

  val solver = f(r * x - d)
  val ans = (1 to 10).map(i => solver())
  println(ans.mkString("\n"))
}

Measured memory_bytes: 25404
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>;

ll dp[102][100002];

signed main() {
    int n, W;
    cin >> n >> W;
    vi w(n), v(n);
    rep(i,n) cin>>w[i]>>v[i];
    FOR(i,w[0], W+1) {
        dp[0][i] = v[0];
    }
    FOR(i, 1, n) {
        rep(j, w[i]) dp[i][j] = dp[i-1][j];
        rep(j, W-w[i]+1) {
            dp[i][j + w[i]] = max(dp[i-1][j] + v[i], dp[i-1][j + w[i]]);
        }
    }
    ll ans = 0;
    rep(i, W+1) ans = max(ans, dp[n-1][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 78336
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");
	public static void main(String[] args) {
		int N=sc.nextInt();
		int v[]=new int[N+1];
		for(int i=1;i<=N;i++) {
			v[sc.nextInt()]=i;
		}
		for(int i=1;i<=N;i++) {
			if(i==N)System.out.print(v[i]);
			else System.out.print(v[i]+" ");
		}
		
	}
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
}
	

Measured memory_bytes: 63772
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#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)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int N;
  cin >> N;
  int answer {};
  srep(i, 1, N+1) {
    if (i%2==0) continue;
    int cnt {};
    srep(j,1, i+1) {
      if (i%j==0) ++cnt;
    }
    if (cnt == 8) {
      ++answer;
    }
  }
  cout << answer << '\n';
}


Measured memory_bytes: 256
na = lambda: list(map(int, input().split()))
h, w = na()
a = [input() for _ in range(h)]

migi = 0
ans = 1
for s in a:
    for cnt, i in enumerate(s):
        if cnt < migi and i == "#":
            ans = 0
        if i == "#":
            migi = cnt
print("Possible" if ans else "Impossible")

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
	int k, s;
	cin >> k >> s;
	int ans = 0;
	for (int x= 0; x <= k; x++){
		for (int y = 0; y <= k; y++) {
			int z = s - x - y;
			if (z >= 0 && z <= k) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

var n, q int
var ps [][]int
var xm []int
var pt []int
var ptd []bool

func main() {

	fmt.Scan(&n, &q)
	ps = make([][]int, n)

	var sc = bufio.NewScanner(os.Stdin)

	for i := 0; i < n-1; i++ {
		sc.Scan()
		s := strings.Split(sc.Text(), " ")
		a, _ := strconv.Atoi(s[0])
		b, _ := strconv.Atoi(s[1])
		a--
		b--
		ps[a] = append(ps[a], b)
		ps[b] = append(ps[b], a)
	}

	xm = make([]int, n)
	for i := 0; i < q; i++ {
		sc.Scan()
		s := strings.Split(sc.Text(), " ")
		p, _ := strconv.Atoi(s[0])
		x, _ := strconv.Atoi(s[1])
		p--
		xm[p] += x
	}

	pt = make([]int, n)
	ptd = make([]bool, n)
	next(0, 0)

	for i := range pt {
		if i == n-1 {
			fmt.Println(pt[i])
		} else {
			fmt.Printf("%d ", pt[i])
		}
	}
}

func next(p, cp int) {
	cp += xm[p]
	pt[p] = cp
	ptd[p] = true
	for _, v := range ps[p] {
		if ptd[v] {
			continue
		}
		ptd[v] = true
		next(v, cp)
	}
}


Measured memory_bytes: 52736
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Node W[] = new Node[n];
		int s=Integer.MAX_VALUE, cost=0;
		for(int i=0; i<n; i++){
			W[i] = new Node();
			W[i].value = sc.nextInt();
			W[i].place = -1;
			if(s > W[i].value) s = W[i].value;
		}

		for(int j=0; j<n; j++){
			int min=Integer.MAX_VALUE, place=-1;
			for(int i=0; i<n; i++){
				if(W[i].place != -1) continue;
				if(min > W[i].value){
					min = W[i].value;
					place = i;
				}
			}
			W[place].place = j;
		}

		for(int i=0; i<n; i++){
			int j=W[i].place;
			if(j != -1 && j != i){
				int cnt=1, min, sum;
				min = sum = W[i].value;
				while(j != i){
					int next = W[j].place;
					if(min > W[j].value) min = W[j].value;
					sum += W[j].value;
					cnt++;
					W[j].place = -1;
					j = next;
				}
				cost += sum+(cnt-2)*min<sum+min+(cnt+1)*s?
				        sum+(cnt-2)*min:
				        sum+min+(cnt+1)*s;
			}
		}

		System.out.println(cost);
	}
}
class Node{
	int value;
	int place;
}



Measured memory_bytes: 31836