akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 using namespace std;
 typedef long long int ll;
  
 // 配列が大きいのでグローバル変数にしてます、あとlong longも忘れずに
 ll dp[55][55][2600] = {};  // i番目までで、k回選んで合計をsにする組み合わせの数
  
 // ====================================================================
  
 int main() {
   ll n, a;
   cin >> n >> a;
   vector<ll> v(n);
   for (int i = 0; i < n; i++) cin >> v[i];
  
   // 俗に言う配るDP
   dp[0][0][0] = 1;  // 初期化
   for (int i = 0; i <= n; i++) {
     for (int k = 0; k <= 50; k++) {
       for (int s = 0; s <= 2500; s++) {
         dp[i + 1][k][s] += dp[i][k][s]; // そのカードを選ばなかった場合
         dp[i + 1][k + 1][s + v[i]] += dp[i][k][s]; // そのカードを選んだ場合
       }
     }
   }
  
   ll ans = 0;
   for (int k = 1; k <= n; k++)
     ans += dp[n][k][a * k]; // k回選んで合計がa*k(つまり平均はa)の組み合わせの数を足す
  
   cout << ans << endl;
 }

Measured memory_bytes: 58496
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <typeinfo>
#include <stdlib.h>

using namespace std;

int main(int argc, char* argv[]){
  int a,b,c,d;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  cout << min(a,b) + min(c,d)<< endl;
  return 0;
}


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

using namespace std;

#define ll long long

int main(void){
    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = 0;

    ans += n / (a+b) * a;
    ans += min(n % (a+b), a);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

bool hantei(int a){
	double b = sqrt(a);

	if(a == 1)
		return false;
	for (int i = 2; i <= b; i++){
//		cout << a << " " << i << "\n";
		if (a % i == 0)
			return false;
	}
	return true;
}

int main(){
	int n;
	int number = 0;
	int many[100000];
	int temp;

	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> many[i];
	}

	for(int i = 1; i <= n; i++){
		if (hantei(many[i]))
			number++;
	}

	cout << number << "\n";
}


Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n) + 1; i++)
#define all(vecto) vecto.begin(), vecto.end()
#define max3(a, b, c) max(a, max(b, c))
#define min3(a,b,c) min(a,min(b,c))
typedef long long ll;

void ans(bool qus){
    if (qus == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Ans(bool qust){
    if (qust == true)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

////////////////---START---////////////////

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    bool s = (abs(c - a) <= d) || ((abs(b - a) <= d) && (abs(c - b) <= d));
    ans(s);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b){
  int r;
  if(a<b) swap(a,b);
  while(b!=0){
    r=a%b;
    a=b;
    b=r;
  }
  return a;
}
    
int main(){
  long long a,b;
  cin>>a>>b;
  long long g=gcd(a,b);
  cout<<a*b/g<<endl;
}

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

#define unsigned int long long
#define p(a, b) pair<a,b>

bool check(int i);

using namespace std;

//ifstream cin("Input.txt");
//ofstream cout("Output.txt");

int main() {
    int n;
    cin >> n;
    int res = 0;
    for(int i = 1; i <= n; i++){
        if(check(i)){
            res++;
        }
    }
    cout << res;
}

bool check(int n) {
    if(n%2==0){
        return false;
    }
    int tot = 0;
    for(int i = 1; i <= n; i++){
        if(n%i==0){
            tot++;
        }
    }
    return tot == 8;
}

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

using namespace std;

int main() {
  string word;
  cin >> word;
  bool flag = true;
  int counter = 0;
  int counter_num = 0;

  for (int i = 0; i < word.length(); i++) {
    if (word[i] == 'A' || word[i] == 'C' || word[i] == 'T' || word[i] == 'G') {
      counter += 1;
    } else {
      if (counter > counter_num) {
        counter_num = counter;
      }
      counter = 0;
    }
  }

  if (counter > counter_num) {
          counter_num = counter;
  }

  cout << counter_num;
}

Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
constexpr ll mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define vsort(v) sort(all(v))

int main() {
    int x,n;cin>>x>>n;
    vector<bool> p(102,true);
    rep(i,n){
        int tmp;cin>>tmp;
        p[tmp]=false;
    }
    int mi=200,ma=-10;
    pair<int,int> res = {200, 0};

    rep(i,102){
        if(p[i]){
            if(i<x) res = {x-i, i};
            else if(res.first > i-x) res = {i-x, i};
            else break;
        }
    }
    cout<<res.second<<endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i = 0; i < (a); i++)
#define reps(i, a, b) for(int i = (a); i < (b); i++)
#define INF 1e9
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;
int main() {
	vi v = vi(3,0);
	vi ans = vi(4,0);
	while(cin >> v[0] >> v[1] >> v[2]) {
		sort(v.begin(), v.end());
		int v0 = v[0] * v[0], v1 = v[1] * v[1], v2 = v[2] * v[2];
		if(v[0] + v[1] > v[2]) ans[0]++;
		else break;
		if(v0 + v1 == v2) ans[1]++;
		if(v0 + v1 > v2) ans[2]++;
		if(v0 + v1 < v2) ans[3]++;
	}
	rep(i, 3) printf("%d ", ans[i]);
	printf("%d\n", ans[3]);
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll h,w;
char a[111][111];
int cnt[33];
ll t1,t2;

int main(){
  cin>>h>>w;
  rep(i,h){
    cin>>a[i];
  }
  ll cnt1=0,cnt2=0;
  t1=h,t2=w;
  if(h%2==1&&w%2==1){
    cnt1++;
  }
  if(h%2!=0){
    cnt2+=w/2;
    h--;
  }
  if(w%2!=0){
    cnt2+=h/2;
    w--;
  }
  h=t1,w=t2;
  rep(i,h)rep(j,w){
    cnt[a[i][j]-'a']++;
  }
  rep(i,26){
    cnt[i]%=4;
    //dbg(cnt[i]);
    if(cnt[i]==1||cnt[i]==3){
      if(cnt1>0)cnt1--;
      else{
        cout<<"No"<<endl;
        return 0;
      }
    }
    if(cnt[i]==2){
      if(cnt2>0)cnt2--;
      else{
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    int x,y;cin>>x>>y;
    if(y%2){
        cout<<"No"<<endl;
    }else{
        if(2*x<=y&&y<=4*x){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3588
package main

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

var sc = bufio.NewScanner(os.Stdin)
var buf = make([]byte, 1000000)

func gets() string {
	sc.Scan()
	return sc.Text()
}

func vec_i(s []string) []int {
	v := make([]int, len(s))
	for i, e := range s {
		v[i], _ = strconv.Atoi(e)
	}
	return v
}

func geti() int {
	n, _ := strconv.Atoi(gets())
	return n
}

type Pair struct {
  x int
  y int
}

func main() {
	sc.Buffer(buf, cap(buf))
  var h, w int
  hw := vec_i(strings.Fields(gets()))
  h = hw[0]
  w = hw[1]
  q := make([]Pair, 0)

	c := make([][]byte, h)
	for i := 0; i < h; i++ {
		// c[i] = vec_i(strings.Split(gets(), ""))
		c[i] = []byte(gets())
	}
  d := make([][]int, h)
  for i := range d {
    d[i] = make([]int, w)
  }
  for i, w := range(c) {
    for j, v := range(w) {
      if v == '#' {
        d[i][j] = 0
        q = append(q, Pair{i, j})
      } else {
        d[i][j] = -1
      }
    }
  }
  p := q[0]
  q = q[1:]
  max := 0
  dx := [4]int{1, 0, -1, 0}
  dy := [4]int{0, 1, 0, -1}
  var xx, yy, x, y, count int
  for {
    xx = p.x
    yy = p.y
    for i := 0; i < 4; i++ {
      x = xx + dx[i]
      y = yy + dy[i]
      if x < 0 || x > h - 1 || y < 0 || y > w - 1 || d[x][y] >= 0 {
        continue
      }
      if c[x][y] == '.' {
        q = append(q, Pair{x, y})
        count = d[xx][yy] + 1
        if max < count {
          max = count
        }
        d[x][y] = count
      }
    }
    if len(q) == 0 {
      break
    }
    p = q[0]
    q = q[1:]
  }
  fmt.Println(max)
}


Measured memory_bytes: 68180
#include <bits/stdc++.h>
 
#include <atcoder/all>
using namespace atcoder;
 
using namespace std;
using ll = long long;
 
int main() {
    int N, M;
    cin >> N >> M;
 
    dsu d(N + 1);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        d.merge(a, b);
    }
    vector<vector<int>> g = d.groups();
    cout << g.size() - 2 << endl;
 
    return 0;
}

Measured memory_bytes: 9024
object Main extends App {

  def rec(m:Int, t:Int):Int = {
    if(m > 0) rec(m/10, t + (m%10))
    else t
  }

  val Array(n, a, b) = io.StdIn.readLine.split(" ").map(_.toInt)

  val ans = (1 to n).foldLeft(0)( (acc,i) => {
    val sum = rec(i, 0)
    if(a <= sum && sum <= b ) acc + i else acc
  })

  println(ans)
}


Measured memory_bytes: 25400
S=list(str(input()))
judge=True
for i, name in enumerate(S):
    if S[i]=="R" and i%2==0:
        continue
    elif S[i]=="L" and i%2!=0:
        continue
    elif S[i]=="U"or S[i]=="D":
        continue
    else:
        print("No")
        judge=False
        break
if judge==True:
    print("Yes")


Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int n, k;
    cin >> n >> k;

    ll ans;
    ans = k*pow(k-1, n-1);
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int even = 0;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (A % 2 == 0) even++;
  }

  int x = 1;
  for (int i = 0; i < N; i++) x *= 3;
  int y = 1;
  for (int i = 0; i < even; i++) y *= 2;

  cout << x - y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<string,string> P;
const int M=1000000007;
class RH {
public:
  unsigned long long p[111],h[111];
  int n;
  void init(string s) {
    n=s.size();
    p[0]=1;h[0]=0;
    for(int i=0; i<n; i++) {
      h[i+1]=h[i]*M+s[i];
      p[i+1]=p[i]*M;
    }
  }
  unsigned long long H() {
    return h[n];
  }
};
map<unsigned long long,vector<string> > m;

void change(string s) {
  int n=s.size();
  for(int i=0; i<n; i++) {
    string t=s.substr(0,i)+s.substr(i+1);
    RH r;
    r.init(t);
    m[r.H()].push_back(s);
    for(int j=0; j<26; j++) {
      t=s;
      t[i]='a'+j;
      r.init(t);
      m[r.H()].push_back(s);
    } 
  }
  for(int i=0; i<=n; i++) {
    for(int j=0; j<26; j++) {
      string t=s.substr(0,i)+(char)('a'+j)+s.substr(i);
      RH r;
      r.init(t);
      m[r.H()].push_back(s);
    }
  }
  for(int i=0; i<n-1; i++) {
    swap(s[i],s[i+1]);
    RH r;
    r.init(s);
    swap(s[i],s[i+1]);
    m[r.H()].push_back(s);
  }
}
int main() {
  int n;
  while(cin >> n && n) {
    m.clear();
    int d;
    cin >> d;
    string s[n];
    for(int i=0; i<n; i++) {
      cin >> s[i];
      change(s[i]);
    }
    vector<P> ans;
    if(d==1) {
      for(int i=0; i<n; i++) {
        RH r;
        r.init(s[i]);
        vector<string> v=m[r.H()];
        for(int j=0; j<v.size(); j++) {
          if(s[i]==v[j]) continue;
          P p=P(s[i],v[j]);
          if(p.first>p.second) swap(p.first,p.second);
          ans.push_back(p);
        }
      }
    } else {
      for(map<unsigned long long,vector<string> >::iterator it=m.begin(); it!=m.end(); it++) {
        vector<string> v=it->second;
        sort(v.begin(),v.end());
        v.erase(unique(v.begin(),v.end()),v.end());
        for(int i=0; i<v.size(); i++) {
          for(int j=i+1; j<v.size(); j++) {
            ans.push_back(P(v[i],v[j]));
          }
        }
      }
    }
    sort(ans.begin(),ans.end());
    ans.erase(unique(ans.begin(),ans.end()),ans.end());
    for(int i=0; i<ans.size(); i++) cout << ans[i].first << "," << ans[i].second << endl;
    cout << ans.size() << endl;
  }
  return 0;
}

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

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		h = sc.nextInt();
		w = sc.nextInt();
		k = sc.nextInt();
		bar = new char[h][w];
		for(int i = 0; i < h; i++) bar[i] = sc.next().toCharArray();
		int min = (h+w+1);
		for(int mask = 0; mask < (1 << (h-1)); mask++) {
			min = Math.min(min, calc(mask));
		}
		System.out.println(min);
	}
	static int h, w, k;
	static char[][] bar;
	static int calc(int mask) {
		HashSet<Integer> set = toset(mask);
		int m = set.size()+1;
		int[] currs = new int[m];
		int res = set.size();
		for(int i = 0; i < w; i++) {
			int[] vals = new int[m];
			int c = 0;
			boolean badmask = false;
			for(int j = 0; j < h; j++) {
				if(bar[j][i] == '1') vals[c]++;
				if(vals[c] > k) badmask = true;
				if(set.contains(j)) c++;
			}
			if(badmask) return h+w+1;
			boolean valid = true;
			for(int j = 0; j < m; j++) {
				currs[j] += vals[j];
				if(currs[j] > k) {
					valid = false; break;
				}
			}
			if(!valid) {
				res++;
				currs = vals;
			}
		}
		return res;
	}
	static HashSet<Integer> toset(int mask){
		HashSet<Integer> res = new HashSet<>();
		for(int i = 0; i < 10; i++) {
			if((mask & (1 << i)) > 0) res.add(i);
		}
		return res;
	}
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
	}

}


Measured memory_bytes: 41408
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 1; i <= n; i++) cin >> a[i], sum += a[i];
	int ans = INF;
	int cur = 0;
	for (int i = 1; i < n; i++)
	{
		cur += a[i];
		ans = min(ans, abs(sum - 2 * cur));
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
 while(1){
  int w,h;
  cin >> h >> w;
  if(w==0&&h==0) break;

  for(int i=1;i<=h;++i){
   for(int j=1;j<=w;++j){
    if(j!=w&&i!=h&&j!=1&&i!=1) cout << ".";
    else cout << "#";
   }
  cout << endl;
  }
 cout << endl;
 }
 return 0;
}

Measured memory_bytes: 3080
def f?(m, f)
  if m ==  -1 || f == -1
    true
  elsif m + f < 30
    true
  else
    false
  end
end

loop do
  m, f, r = gets.chomp.split.map(&:to_i)
  break if [m, f, r].all? { |n| n == -1 }

  case
  when f?(m, f) then puts 'F'
  when m + f >= 80 then puts 'A'
  when m + f <  80 && m + f >= 65 then puts 'B'
  when m + f <  65 && m + f >= 50 then puts 'C'
  else
    if r >= 50
      puts 'C'
    else
      puts 'D'
    end
  end
end

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

typedef long long int ll;

const int div_num = 1000000007;
int N;
ll ans;
vector<bool> pt;

void make_pt(int n) {
	pt.resize(n + 1, (bool)true);
	pt[0] = pt[1] = false;
	for (int i = 4; i <= n; i += 2) pt[i] = false;
	int sqrt_max = (int)sqrt((double)n);
	for (int i = 2; i <= sqrt_max; ++i) {
		if (pt[i]) {
			for (int j = i * i; j <= n; j += i)
				pt[j] = false;
		}
	}
}

int calcu(int num, int div) {
	int p = 0;
	int x = num;
	while (true) {
		if (x % div != 0)
			break;
		x /= div;
		++p;
	}
	return p;
}

void solve(int n) {
	ans = 1;
	for (int i = 2; i <= n; ++i) {
		if (pt[i] != true)
			continue;
		int cnt = 0;
		for (int j = i; j <= n; ++j) {
			cnt += calcu(j, i);
		}
		if (cnt != 0) {
			ans = ans * (ll)(cnt + 1);
			ans = ans % div_num;
		}
	}
}

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

	solve(N);

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;


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

  int n; cin >> n;
  vector<int> a(n+2);
  a.push_back(0);
  rep(i, n) cin >> a[i+1];
  a.push_back(0);

  vector<int> c(n+1);
  rep(i, n+1) {
    c[i] = abs(a[i] - a[i+1]);
  }

  ll total = SUM(c);

  rep(i, n) {
    ll ans = total - c[i] - c[i+1];
    ans += abs(a[i] - a[i+2]);
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 2040
import java.util.*;class Main{public static void main(String[] a){new Main();}public Main(){for(int i=0,e=2;i<168;i++){for(;p(e)<1; e++);p[i]=e++;}for(Scanner s=new Scanner(System.in);s.hasNext();){int c=0;for(int n=s.nextInt();n>1;)c+=p(n--)>0?1:0;System.out.println(c);}}int p(int n){for(int e:p)if(e>0&&n!=e&&n%e<1)return 0;return 1;}int[]p=new int[168];}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1LL << 30;

// dp[i][j] := i個目の品物(何個でも選べる)までで重さjを作るときの価値(最大化)
int dp[101][10101];
    
int main() {
    int N, W;
    cin >> N >> W;
    vector< int > v(N), w(N);
    for (int i=0; i<N; ++i) cin >> v[i] >> w[i];
    
    for (int i=0; i<N; ++i) {
        for (int j=0; j<=W; ++j) {
            dp[i+1][j] = max(dp[i][j], dp[i+1][j]);
            if (j >= w[i]) {
                dp[i+1][j] = max(dp[i+1][j], dp[i+1][j-w[i]] + v[i]);
            }
        }
    }
    
    int ans = 0;
    for (int i=0; i<=W; ++i) ans =max(ans, dp[N][i]);
    cout << ans << endl;
    
    /*
    for (int i=0; i<=N; ++i) {
        for (int j=0; j<=W; ++j) {
            printf("%3d ", dp[i][j]);;
        }
        printf("\n");
    }
    */
    
    return 0;
}


Measured memory_bytes: 7044
from collections import defaultdict


def dfs(s, t, links):
    visited = set()
    q = [(s, 0)]
    while q:
        v, used = q.pop()
        if v == t:
            return used
        visited.add(v)
        for lb, u in links[v]:
            if u in visited:
                continue
            q.append((u, used | lb))


n = int(input())
links = [set() for _ in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    lb = 1 << i
    links[a].add((lb, b))
    links[b].add((lb, a))
conditions = []
m = int(input())
for i in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    conditions.append(dfs(u, v, links))

link_conditions = [int(''.join(b), 2) for b in zip(*map(('{:0' + str(n - 1) + 'b}').format, conditions))]

dp = defaultdict(lambda: 0)
dp[0] = 1
for lc in link_conditions:
    for fulfilled, pattern in list(dp.items()):
        dp[fulfilled | lc] += pattern
print(dp[(1 << m) - 1])


Measured memory_bytes: 216924
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B;
	cin >> A >> B;
	if (A + B <= 16 && A <= 8 && B <= 8) {
		cout << "Yay!"<< endl;
	}
	else {
		cout << ":(" << endl;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,s=0;
  cin >> N;
  int a[3*N],b=3*N;
  for(int i=0;i<b;i++)
    cin >> a[i];
  sort(a,a+b);
  for(int j=N;j<b;j+=2)
  	s+=a[j];
  cout << s << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

ll gcd(ll A, ll B) {
    if (A > B) swap(A, B);
    if (A == 0) return B;
    return gcd(B%A, A);
}

ll countDivBy(ll N, ll A, ll B) {
    if (B < A) return 0;
    ll loBound = A / N; loBound = loBound * N; if (loBound < A) loBound += N;
    if (loBound > B) return 0;
    ll hiBound = B / N; hiBound = hiBound * N;
    if (hiBound < A) return 0;
    ll count = hiBound - loBound; count /= N; count++;
    return count;
}

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

    ll A, B, C, D; cin >> A >> B >> C >> D;

    ll divC = countDivBy(C, A, B);
    ll divD = countDivBy(D, A, B);
    ll divBoth = countDivBy((C*D)/gcd(C, D), A, B);

    cout << (B-A+1)-divC-divD+divBoth << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;

 
int main() {
    int N; cin >> N;
    vector<int> V(N), A_(N);
    for(int i = 0; i < N; i++) cin >> V[i];
    ll cons = 0;
    for(int i = 0; i < N-1; i++){
        if(i%2==0) cons -= V[i];
        else cons += V[i]; 
    }
    int A;
    for(int a = 0; a <= V[0]; a++){
        int z = cons+a;
        if(a+z == V[N-1]){
            A = a;
            break;
        }
    }
    A_[0] = A;
    for(int i = 1; i < N; i++){
        A_[i] = V[i-1] - A_[i-1];
    }
    for(int i = 0; i < N; i++) cout << 2*A_[i] << " ";
    cout << endl;
    
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
ll N;
string S;

void solve() {
	ll i,j,k,l,r,x,y; string s;
	cin>>N;
	cin>>S;
    ll f[N];
    f[0]=0;
    FOR(i,N){
        if(i==0) continue;
        if('E'==S[i])
            f[0] += 1;
    }
    ll ret = f[0];
    FOR(i,N-1){
        int opt =0;
        if(S[i]==S[i+1]){
            if('W'==S[i]) opt = 1;
            else opt = -1;
        }
        f[i+1] = f[i] + opt;
        if(f[i+1]<ret) ret=f[i+1];
    }
    //FOR(i,N) cout<<f[i]<<endl;
    cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Measured memory_bytes: 2964
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rer(i, a, b) for(int i = a - 1; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<pi, pi> ppi;
typedef vector<ll> vec;

const int MAX_N = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const ll inf = 1LL << 60;

void Debug() {cout << '\n'; }

template<class FIRST, class... REST> 
void Debug(FIRST arg, REST... rest) { cout << arg << " "; Debug(rest...); }

template<class T>
ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";
	if(!v.empty()) {
		rep(i, 0, (int)v.size() - 1) out << v[i] << ", ";
		out << v.back();
	}
	out << "]";
  return out;
}

template<class S, class T>
ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";
	return out;
}

///g++ -g3 -std=c++0x -DLOCAL -Wall -ftrapv -D_GLIBCXX_DEBUG -Wl,-stack,268435456 -o
///g++ -O2 -std=c++0x -DLOCAL -Wall -Wl,-stack,268435456 -o

///////////////////////////////////////////////////////////////////////


ll fac[MAX_N];

ll mod_pow(ll a, ll n) {
	if(n == 0) return 1;
	ll res = mod_pow(a, n / 2);
	if(n % 2 == 0) return res * res % mod;
	else return a * res % mod * res % mod;
}

ll inv_(ll a) {
	return mod_pow(a, mod - 2);
}

ll C_(int a, int b) { //assume a >= b
	if(a < b || b < 0 || a < 0) return 0;
	return fac[a] * inv_(fac[b]) % mod * inv_(fac[a - b]) % mod;
}

int N;
int A[MAX_N];
int L, R;
int cnt[MAX_N];

void solve() {
	cin >> N;
	N++;
	rep(i, 0, N + 1) {
		cin >> A[i];
		cnt[A[i]]++;
	}
	int t = -1;
	rep(i, 1, N + 1) {
		if(cnt[i] == 2) t = i;
	}
	int prev = -1;
	rep(i, 0, N + 1) {
		if(t == A[i]) {
			if(prev == -1) {
				prev = i;
				L = prev;
			}
			else {
				R = N - i - 1;
				break;
			}
		}
	}
	fac[0] = 1; fac[1] = 1;
	rep(i, 2, N + 1) {
		fac[i] = fac[i - 1] * i % mod;
	}
	rep(i, 1, N + 1) {
		cout << (C_(N, i) - C_(L + R, i - 1) + mod) % mod << "\n";
	}
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);	
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}




Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
  int main(void){
    int i = 0 ;
 
   char A;
   char B;
   char C;
 
    
   char D;
   char E;
   char F;
 
    cin >> A >> B >> C ;
    cin >> D >> E >> F ;
    
    if(A == D){
    i++;
    }
    if(B==E){
    i++;
    }
    if(C==F){
    i++;
    }
    cout<<i;
      
    
    
    //cout << A << B << C << D << E << F;
  }


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

int main() {
  
  int N, P; cin >> N >> P;
  
  bool flag = false;
  
  for (int i = 0; i < N; i++) {
    int A; cin >> A;
    if (A % 2 == 1) flag = true;
  }
  
  if (flag) cout << int64_t(pow(2, N - 1)) << endl;
  
  else {
    
    if (P == 0) cout << int64_t(pow(2, N)) << endl;
    
    else cout << 0 << endl;
    
  }
  
}

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

int main() {
	int n;
	cin>>n;
	long long  arr[n];
	for(int i=0;i<n;i++)
	cin>>arr[i];
	long odd=0;
	for(int i=0;i<n;i++)
	{
		 if(arr[i] % 2 != 0)
            odd++;
	}
	if(odd != 0)
        cout << "first" << endl;
    else
        cout << "second" << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define min(x,y) ((x)<(y)?(x):(y))
#define max(x,y) ((x)>(y)?(x):(y))
#define ll long long

using namespace std;

const int maxn=1e5+5;

int fi[maxn],dui[maxn*2],ne[maxn*2],qc[maxn],dui1[maxn*2];
ll de[maxn],ans,mi;
int size[maxn];
int i,j,k,l,m,n,x,y,z,c1,c2,now;

void add(int x,int y,int z){
	if (fi[x]==0) fi[x]=++now; else ne[qc[x]]=++now;
	dui[now]=y; dui1[now]=z; qc[x]=now;
}
void dfs_size(int x,int y){
	size[x]=1;
	for(int i=fi[x];i;i=ne[i]){
		if (dui[i]==y) continue;
		dfs_size(dui[i],x);
		size[x]=size[x]+size[dui[i]];
	}
}
void dfs_root(int x,int y){
	int z=size[1]-size[x];
	for(int i=fi[x];i;i=ne[i]){
		if (dui[i]==y) continue;
		z=max(z,size[dui[i]]);
		dfs_root(dui[i],x);
	}
	if (z<l){
		l=z; c1=x; c2=0;
	} else if (z==l) c2=x;
}
void dfs_dep(int x,int y){
	for(int i=fi[x];i;i=ne[i]){
		if (dui[i]==y) continue;
		de[dui[i]]=de[x]+dui1[i];
		dfs_dep(dui[i],x);
	}
	ans=ans+de[x]+de[x];
}
int main(){
//	freopen("018d.in","r",stdin);
	scanf("%d",&n);
	fo(i,1,n-1){
		scanf("%d%d%d",&x,&y,&z);
		add(x,y,z); add(y,x,z);
	}
	dfs_size(1,0);
	l=n+1;
	dfs_root(1,0);
	dfs_dep(c1,0);
	if (c2==0){
		mi=1e16;
		fo(i,1,n) if (i!=c1) mi=min(mi,de[i]);
	} else mi=de[c2];
	printf("%lld\n",ans-mi);
	return 0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

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

  int ans = 0;
  rep(i, a, b + 1) {
    if (c % i == 0)
      ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3124
# -*- coding: utf-8 -*-
n,m = map(int, input().split())
i=0
lst = []
while i < m: 
    lst.append(list(map(int, input().split())) + [i])
    i+=1
lst = sorted(lst)
j=0
i=1
for k in lst:
    if i != k[0]:
        i=k[0]
        j=1
        k[1]=i*1000000+j
    else:
        j+=1
        k[1]=i*1000000+j

#ans
for ans in sorted(lst, key=lambda x:x[2]):
    print('{0:012d}'.format(ans[1]))


Measured memory_bytes: 29488
#![allow(unused_imports)]
#![allow(dead_code)]
use proconio::input;
use proconio::fastout;
use proconio::marker::{Chars};

#[fastout]
fn main() {
    input! {
        a:i32,
    }
    if a<=999{
        println!("{}","ABC");
    }else{
        println!("{}","ABD");
    }
}

Measured memory_bytes: 2120
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll h; cin >> h;
    ll cnt = 1;
    ll ans = 0;
    while(h > 0){
        ans += cnt;
        cnt *= 2;
        h /= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include<bits/stdc++.h>
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define pb push_back
#include <x86intrin.h>
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 1e5 + 55, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	map<char, int> cnt;
	for(auto i : s) cnt[i]++;
	for(auto i : cnt) if(i.second!=2) return cout << "No", 0;
	cout << "Yes";
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<int> X(N);
    for(int i=0; i<N; i++) cin >> X[i];

    long long int ans = LONGINF;
    for(int i=0; i<=100; i++) {
        long long int sum = 0;
        for(int j=0; j<N; j++) {
            sum += 1LL * (i - X[j]) * (i - X[j]);
        }
        chmin(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

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

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
void roll(vector<int>& dice, int a, int b, int c, int d){
  int tmp = dice[a];
  dice[a] = dice[b];
  dice[b] = dice[c];
  dice[c] = dice[d];
  dice[d] = tmp;
}
vector<int> roll_r(int r, vector<int> dice){
  switch(r){
    case 0:
      roll(dice, 0, 3, 5, 2);
      break;
    case 1:
      roll(dice, 0, 4, 5, 1);
      break;
    case 2:
      roll(dice, 0, 2, 5, 3);
      break;
    case 3:
      roll(dice, 0, 1, 5, 4);
      break;
  }
  return dice;
}

struct S{
  int x, y;
  int c;
  vector<int> d;
  S(int x, int y, int c, vector<int> d) : 
    x(x), y(y), c(c), d(d) {}
  bool operator < (const S& s) const {
    if(c != s.c) return c > s.c;
    if(x != s.x) return x < s.x;
    if(y != s.y) return y < s.y;
    else return d < s.d;
  }
};
typedef pair<int, int> P;

//{TOP, +Y, +X, -X, -Y, BOTTOM}
int main(){
  int H, W;
  while(cin>>H>>W && H){
    int grid[10][10];
    REP(i, H)REP(j, W) cin>>grid[i][j];
    int sx, sy, gx, gy;
    cin>>sy>>sx>>gy>>gx;
    priority_queue<S> que;
    int start[] = {1, 2, 3, 4, 5, 6};
    que.push(S(sx, sy, 0, vector<int>(start, start + 6)));
    set< pair<P, vector<int> > > used;
    while(!que.empty()){
      S s = que.top(); que.pop();
      if(s.x == gx && s.y == gy){
        cout<<s.c<<endl;
        break;
      }
      if(used.count(make_pair(P(s.x, s.y), s.d))) continue;
      used.insert(make_pair(P(s.x, s.y), s.d));
      REP(r, 4){
        int nx = s.x + dx[r];
        int ny = s.y + dy[r];
        if(valid(nx, ny, W, H)){
          vector<int> nd = roll_r(r, s.d);
          if(!used.count(make_pair(P(nx, ny), nd))){
            que.push(S(nx, ny, grid[ny][nx] * nd[5] + s.c, nd));
          }
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int main(){
    int a, b, c; cin >> a >> b >> c;
    if(a <= c and c <= b) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

A = I()
print(A+A**2+A**3)


Measured memory_bytes: 67228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[105][105][2];
ll K;
ll countInRangeUtil(ll pos, ll cnt, ll tight,vector<ll> num){
	if (pos == num.size()) {
		if (cnt == K)return 1;
		return 0;
	}
	if (dp[pos][cnt][tight] != -1)return dp[pos][cnt][tight];
	ll ans = 0;
	ll limit = (tight ? 9 : num[pos]);
	for (ll dig = 0; dig <= limit; dig++) {
		ll currCnt = cnt;
		if (dig != 0)currCnt++;
		ll currTight = tight;
		if (dig < num[pos])
			currTight = 1;
		ans += countInRangeUtil(pos + 1, currCnt,currTight, num);
	}
	return dp[pos][cnt][tight] = ans;
}
ll countInRange(string x){
	vector<ll> num;
	for(ll i=0;i<x.size();i++)num.push_back(x[i]-'0');
	memset(dp, -1, sizeof(dp));
	return countInRangeUtil(0, 0, 0, num);
}

int main(){
    string n;
	cin>>n>>K;
	cout << countInRange(n);
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

int N, Q;
string s;

int main() {
    cin >> N >> Q;
    cin >> s;

    int accum[100010] = {0};

    for (int i = 1; i < N; i++) {
        if (s[i-1] == 'A' && s[i] == 'C') accum[i] = accum[i-1] + 1;
        else accum[i] = accum[i-1];
    }

    rep(i, Q) {
        int l, r; cin >> l >> r;
        cout << accum[r-1] - accum[l-1] << endl;
    }
}


Measured memory_bytes: 1408
import std.stdio, std.string, std.algorithm, std.conv, std.array;

void main() {
  int times; readf("%d\n", &times);
  for(int t = 0; t < times; t++) {
    int col, row;
    int[10][10] wrong1, wrong2;
    int[10][3][3] wrong3;
    int[][] field;

    for(int i = 0; i < 9; i++) {
      field ~= readln.chomp.split(" ").map!(to!int).array;
    }
  
    for(int i = 0; i < 9; i++) {
      for(int j = 0; j < 9; j++) {
        wrong1[i][field[i][j]]++;
        wrong2[j][field[i][j]]++;
        wrong3[i / 3][j / 3][field[i][j]]++;
      }
    }

    for(int i = 0; i < 9; i++) {
      for(int j = 0; j < 9; j++) {
        bool result = (wrong1[i][field[i][j]] != 1 ||
                       wrong2[j][field[i][j]] != 1 ||
                       wrong3[i / 3][j / 3][field[i][j]] != 1);
        writef("%s%d%s",  result ? "*" : " ", field[i][j], j == 8 ? "\n" : "");
      }
    }
    if (t != (times - 1)) writeln;
  }
}

Measured memory_bytes: 1248
(defn input []
  (->> (repeatedly 2 read-line)
    (map (comp
           (partial map #(Integer/parseInt %))
           #(clojure.string/split % #"\s")))))

(defn Snake-Toy [[[N K] L]]
  ((comp
     (partial reduce +)
     (partial take-last K)
     sort)
   L))

(-> (input)
  Snake-Toy
  println)

Measured memory_bytes: 65024
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){	
	int score[200],val,ctn[200];
	memset(score, 0, sizeof(score));
	fill(ctn,ctn + 200 , 1);

	cin >> val;
	int a, b, c, d;
	for (int i = 0; i < (val*(val-1))/2; i++){
		cin >> a >> b >> c >> d;
		if (c < d)
			score[b-1] += 3;
		else if (c > d)
			score[a-1] += 3;
		else if (c == d){
			score[a-1]++;
			score[b-1]++;
		}
	}
	for (int i = 0; i < val; i++){
		for (int j = 0; j < val; j++){
			if (score[i] < score[j])
				ctn[i]++;
		}
	cout << ctn[i] << endl;
	}
}

Measured memory_bytes: 1160
/*********************************************************************************************/
/**                                                                                          //
//                            _ooOoo_                                                        //
//                           o8888888o                                                       //
//                           88" . "88                                                       //
//                           (| -_- |)                                                       //
//                            O\ = /O                                                        //
//                        ____/`---'\____                                                    //
//                      .   ' \\| |// `.                                                     //
//                       / \\||| : |||// \                                                   //
//                     / _||||| -:- |||||- \                                                 //
//                       | | \\\ - /// | |                                                   //
//                     | \_| ''\---/'' | |                                                   //
//                      \ .-\__ `-` ___/-. /                                                 //
//                   ___`. .' /--.--\ `. . __                                                //
//                ."" '< `.___\_<|>_/___.' >'"".                                             //
//               | | : `- \`.;`\ _ /`;.`/ - ` : | |                                          //
//                 \ \ `-. \_ __\ /__ _/ .-` / /                                             //
//         ======`-.____`-.___\_____/___.-`____.-'======                                     //
//                            `=---='                                                        //
//                                                       //                                  //
//         .............................................                                     //
//                  佛祖保佑             永无BUG                                            //
********************************************************************************************/
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
const int mod=1000000009;
int vis[10000];
int main()
{
    int a,b,c;
    cin>>a;
    int sum=0;
    for(int i=1;i<=a;i++)
        sum+=i;
    cout<<sum<<endl;
}


Measured memory_bytes: 256
import itertools
n, m, R = map(int, input().split())
r = list(map(int, input().split()))
dis = [[float("inf") for _ in range(n)] for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    dis[a - 1][b - 1] = c
    dis[b - 1][a - 1] = c


def war(dis):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if dis[i][j] > dis[i][k] + dis[k][j]:
                    dis[i][j] = dis[i][k] + dis[k][j]
    return dis


dis = war(dis)
ans = float('inf')
it = itertools.permutations(r)
for l in it:
    tmp = 0
    for u, v in zip(l, l[1:]):
        tmp += dis[u-1][v-1]
        if tmp > ans:
            break
    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 5536
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;

int main(){
  int N;
  cin >> N;
  map<int, int> mp;
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    mp[a]++;
    mp[a-1]++;
    mp[a+1]++;
  }
  int M=0;
  for(auto m: mp){
    M = max(M,m.second);
  }
  cout << M << endl;
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == '1') ++counter;
    if (s[1] == '1') ++counter;
    if (s[2] == '1') ++counter;
    cout << counter << endl;
}

Measured memory_bytes: 3588