akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#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 INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main()
{
  ll n;
  cin >> n;
  ll x = 0;
  for (ll i = 1; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      x = i;
    }
  }
  ll y = n / x;
  cout << x + y - 2 << "\n";
  return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;
 
int main() {
   int n,x;
   cin>>n;
   x=n;
   
   int sum=0;
   while(x>0){
       sum+=x%10;
       x/=10;
   }
  if(n%sum==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define nmax 22
#define inf 999999999
#define lld long long
#define ld long double
using namespace std;
int n, m;
char mat[nmax][nmax];
int d1[nmax][nmax], d2[nmax][nmax];
bool u1[nmax][nmax], u2[nmax][nmax];
int dl[] = {-1,0,1,0};
int dc[] = {0,1,0,-1};
bool interior(int i, int j){
    return i>=1&&j>=1&&i<=n&&j<=m;
}
void lee(int x, int y, int d[nmax][nmax], bool u[nmax][nmax]){
    queue<pii>q;
    d[x][y] = 0;
    q.push(mp(x,y));
    u[x][y] = true;
    while (!q.empty()){
        auto act = q.front();
        q.pop();
        int i = act.first;
        int j = act.second;
        for (int k=0;k<4;++k){
            if (!interior(i+dl[k],j+dc[k])){
                continue;
            }
            if (u[i+dl[k]][j+dc[k]]){
                continue;
            }
            if (mat[i+dl[k]][j+dc[k]] != '.'){
                continue;
            }
            d[i+dl[k]][j+dc[k]]=d[i][j]+1;
            u[i+dl[k]][j+dc[k]]=true;
            q.push(mp(i+dl[k],j+dc[k]));
        }
    }
}
int main(){
    cin>>n>>m;
    for (int i=1;i<=n;++i){
        for (int j=1;j<=m;++j){
            cin>>mat[i][j];
        }
    }
    int ans = 0;
    for (int i=1;i<=n;++i){
        for (int j=1;j<=m;++j){
            if (mat[i][j] != '.'){
                continue;
            }
            memset(d1,0,sizeof(d1));
            memset(u1,0,sizeof(u1));
            lee(i,j,d1,u1);
            for (int i=1;i<=n;++i){
                for (int j=1;j<=m;++j){
                    ans = max(ans, d1[i][j]);
                }
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
use std::fmt;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;

fn main() {
	let stdin = stdin();
	let mut scan = InputScanner::new(stdin.lock(),256);

	let n:usize = scan.next();
	let k:usize = scan.next();

	let r = if n == 1 {
		k
	} else {
		k * pow(k-1,n-1)
	};

	println!("{}",r);
}
fn pow(n:usize,e:usize) -> usize {
	if e > 1 {
		let a = pow(n,e/2);

		if e % 2 == 0 {
			a * a
		} else {
			a * a * n
		}
	} else {
		n
	}
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}



Measured memory_bytes: 4352
h,w = map(int,input().split())
data = []
sa = ['.']*(w+2)
data.append(sa)
for i in range(h):
    s = input()
    s = ('.'+s+'.').strip()
    data.append(s)
data.append(sa)

dx = [1,-1,0,0,1,-1,1,-1]
dy = [0,0,1,-1,1,1,-1,-1]

for i in range(1,h+1):
    for j in range(1,w+1):
        if data[i][j] == '#':
            print('#',end='')
            continue
        cnt = 0
        for k in range(8):
            if data[i+dx[k]][j+dy[k]] == '#': cnt += 1
        print(cnt,end='')
    print()



Measured memory_bytes: 3444
import sys

N, Q = map(int, sys.stdin.readline().strip().split())
S = sys.stdin.readline().strip()
ls = len(S)

index = [0 for _ in range(len(S)+1)]
for i in range(len(S)):
    if S[i:i+2] == "AC":
        index[i+1] = 1
for i in range(ls):
    index[i+1] += index[i]

# print(index)

for _ in range(Q):
    l, r = map(int, sys.stdin.readline().strip().split())
    print(index[r-1] - index[l-1])

Measured memory_bytes: 7972
class dice():
    top = 1
    flont = 2
    right = 3
    def do_N(self):
        temp = self.flont
        self.flont = 7-self.top
        self.top = temp

    def do_S(self):
        temp = 7-self.flont
        self.flont = self.top
        self.top = temp

    def do_E(self):
        temp = self.top
        self.top = 7-self.right
        self.right = temp

    def do_W(self):
        temp = 7-self.top
        self.top = self.right
        self.right = temp

num1 = list(map(int, input().split()))
q = int(input())
dice1 = dice()

for i in range(q):
    top, flont = map(int, input().split())
    if num1[dice1.flont-1] == flont and num1[dice1.top-1] == top:
        ans = num1[dice1.right-1]
    for j in range(4):
        for k in range(4):
            dice1.do_E()
            if num1[dice1.flont-1] == flont and num1[dice1.top-1] == top:
                ans = num1[dice1.right-1]
        dice1.do_N()
        if num1[dice1.flont-1] == flont and num1[dice1.top-1] == top:
            ans = num1[dice1.right-1]

    dice1.do_S()
    dice1.do_E()
    if num1[dice1.flont-1] == flont and num1[dice1.top-1] == top:
        ans = num1[dice1.right-1]
    for j in range(4):
        for k in range(4):
            dice1.do_E()
            if num1[dice1.flont-1] == flont and num1[dice1.top-1] == top:
                ans = num1[dice1.right-1]
        dice1.do_N()
        if num1[dice1.flont-1] == flont and num1[dice1.top-1] == top:
            ans = num1[dice1.right-1]


    print(str(ans))


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

typedef long long ll;
using namespace std;

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

	int n; cin >> n;

	for (int i = 0;i < n;i++){
		char a[6]; cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
		double h = 10*(a[0]-'0') + (a[1]-'0');
		double m = 10*(a[3]-'0') + (a[4]-'0');
		double ha = 30 * h + m/2;
		double ma = 6 * m;
		double d = max(ha,ma) - min(ha,ma);
		if(d < 30 || d > 330) cout << "alert" << endl; 
		else if(d < 90 || d > 270) cout << "warning" << endl;
		else cout << "safe" << endl;
	}

	return 0;

}



Measured memory_bytes: 3156
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
using namespace std;
using ll=long long;

int main(){
    int n,k;
    cin>>n>>k;
    cout<<n-k+1<<endl;
    return 0;
}

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

using namespace std;

double poww(double x) {
	return x * x;
}

int main() {
	int n; cin >> n;
	vector<pair<double, double> > xy(n);
	for (auto& a : xy) cin >> a.first >> a.second;
	sort(xy.begin(), xy.end());
	double ans = 0;
	int cnt = 0;
	do {
		double tmp = 0;
		for (int i = 1; i < n; ++i) {
			tmp += sqrt(poww(xy[i - 1].first - xy[i].first) +
				poww(xy[i - 1].second - xy[i].second));
		}
		ans = (ans * cnt + tmp) / (cnt + 1);
		++cnt;
	} while (next_permutation(xy.begin(), xy.end()));
	printf("%.10f\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

class Node {
public:
	int key;
	Node* left;
	Node* right;
	Node* parent;
	Node() {left = right = parent = NULL;}
	Node(int key) { this->key = key; left = right = parent = NULL;}
	~Node(){}
};

void insert(Node** T, Node* z)
{	
	Node* y = NULL;
	Node* x = *T; // address of root
	while ( x != NULL ) {
		y = x;
		if (z->key < x->key) x = x->left;
		else x = x->right;
	}
	z->parent = y;
	
	if ( y == NULL ) *T = z; // T is empty
	else {
		if (z->key < y->key) y->left = z;
		else y->right = z;
	}
}

bool find(Node *T, int key)
{
	if (T == NULL) return false;
	
	if (key == T->key) return true;
	if (key < T->key) return find(T->left, key);
	else return find(T->right, key);
}

void walk_preorder(Node* T)
{
	std::cout << " " << T->key;
	if (T->left != NULL) walk_preorder(T->left);
	if (T->right != NULL) walk_preorder(T->right);
}

void walk_inorder(Node* T)
{
	if (T->left != NULL) walk_inorder(T->left);
	std::cout << " " << T->key;
	if (T->right != NULL) walk_inorder(T->right);
}

void deleteNodes(Node* x)
{
	if (x->left != NULL) deleteNodes(x->left);
	if (x->right != NULL) deleteNodes(x->right);
	delete x;
}
	
int main()
{
	std::string strn;
	getline(std::cin, strn);
	
	int n = std::stoi(strn);
	
	Node* BST = NULL;
	
	for (int i=0; i<n; i++) {
		std::string buf;
		getline(std::cin, buf);
		int pos = buf.find(' ', 0);
		if (pos == std::string::npos) {
			// print
			walk_inorder(BST); std::cout << std::endl;
			walk_preorder(BST); std::cout << std::endl;
		}
		else {
			std::string op = buf.substr(0, pos);
			int key = std::stoi(buf.substr(pos+1));
			if ( op == "insert") {
				Node* z = new Node(key);
				insert(&BST, z);
			}
			else if ( op == "find" ) {
				if (find(BST, key)) std::cout << "yes" << std::endl;
				else std::cout << "no" << std::endl;
			}
		}
	}
	
	deleteNodes(BST);
	
	return 0;
}



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

using namespace std;

int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x, a;
    cin >> x >> a;
    if (x < a) {
        cout << 0;
    }
    else {
        cout << 10;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;

int main(){
  int n,a,b;

  cin>>n>>a>>b;

  int t;
  int x,y,z;
  x=y=z=0;
  for(int i=0;i<n;i++){
    cin>>t;
    if(t<=a) x++;
    else if(t<=b) y++;
    else z++;
  }
  cout<<min(x,min(y,z))<<endl;
  return 0;
}


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

int main() {
  int a,b,c,d,e,f,g;
  cin >>a >>b >>c >>d;
  e = std::abs(c-a);
  f = std::abs(b-a);
  g = std::abs(c-b);
  if(e<=d){
    cout <<"Yes" <<endl;
  }
  else if(f<=d&&g<=d){
    cout <<"Yes" <<endl;
  }
  else{
    cout <<"No" <<endl;
  }
}

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

int main(){
	int n;
	cin >> n;
	map<string, int> list;
	
	int ma = 0;
	rep(i, n){
		string s;
		cin >> s;
		list[s]++;
		ma = max(ma, list[s]);
	}

	for(auto p : list){
		if(p.second == ma) cout << p.first << endl;
	}

	return 0;
}

Measured memory_bytes: 25216
import math
import bisect
N, M = map(int, input().split())

res = []
for i in range(1, int(math.sqrt(M))+1):
    if M % i == 0:
        res.append(i)
        res.append(M//i)
res.sort()
print(res[bisect.bisect_right(res, M//N)-1])


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n,m,c,x;
    cin >> n >> m >> c;
    vector<int> b(m);
    for(int i=0;i<m;i++) cin >> b[i];
    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0;i<n;i++){
        int sum=0;
        for(int j=0;j<m;j++){
            cin >> a[i][j];
            sum+=a[i][j]*b[j];
        }
        if(sum+c>0) x++;
    }
    cout << x << endl;
 }


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<string>
#include<queue>
#include<iostream>
#define REP(i, n) for(int i = 0, ed_##i = n; i < ed_##i; i++)
#define FOR(i, n) for(int i = 1, ed_##i = n; i <= ed_##i; i++)
#define bit(x) (1 << (x))
#define bitl(x) (1LL << (x))
#define sqr(x) ((x) * (x))
#define sz(x) ((int)(x.size()))
#define cnti(x) (__builtin_popcount(x))
#define cntl(x) (__builtin_popcountll(x))
#define clzi(x) (__builtin_clz(x))  // Leading zeros
#define clzl(x) (__builtin_clzll(x))
#define ctzi(x) (__builtin_ctz(x))
#define ctzl(x) (__builtin_ctzll(x))

#ifdef QWERTIER
#define err(x) cerr << #x << " : " << x << endl
#else
#define err(x)
#endif

typedef long long LL;
using namespace std;

typedef pair<int,int> pii;
#define MP make_pair

#define N 100010
char s[N];
int n;
int a[N];
#define S 0
#define W 1

int calc(int a, int b, char c) {
  return (c == 'x') ^ (b == W) ^ (a == W);
}
bool check() {
  for (int i = 0; i + 2 < n; i++) {
    a[i+2] = calc(a[i], a[i+1], s[i+1]);
  }
  return (a[0] == calc(a[n-2], a[n-1], s[n-1])) && (a[1] == calc(a[n-1], a[0], s[0]));
}
void print_ans() {
  REP (i, n) {
    putchar(a[i] == S ? 'S' : 'W');
  }
}

int main(){
#ifdef QWERTIER
  freopen("in.txt","r",stdin);
#endif
  scanf("%d", &n);
  scanf("%s", s);
  int found = 0;
  REP (i, 2) {
    REP (j, 2) {
      a[0] = i;
      a[1] = j;
      if (check() && !found) {
        print_ans();
        found = 1;
      }
    }
  }
  if (!found)
    puts("-1");
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
using namespace std;
 
long long int gcd( long long int a, long long int b ) {
  return b ? gcd( b, a % b ) : a ;
}
long long int lcm( long long int m, long long int n ) {
  if ( m == 0 || n == 0 ) return 0;
  return ( ( m / gcd( m, n ) ) * n );
}
 
int main() {

  while( true ) {
    long long int n;
    cin >> n;
    if ( n == 0 ) break;
    
    vector< long long int > p, q, r, b;
    for ( long long int i = 0; i < n; i++ ) {
      long long int in_p, in_q, in_r, in_b;
      cin >> in_p >> in_q >> in_r >> in_b;
      p.push_back( in_p );
      q.push_back( in_q );
      r.push_back( in_r );
      b.push_back( in_b );
    }
    
    for ( long long int i = 0; i < n; i++ ) {
      for ( long long int j = 0; j < n; j++ ) {
	
	if ( r[j] <= 0 && b[j] <= 0 ) {
	  
	  if ( r[j] == 0 ) {
	    r[j] = 1;
	  }else {
	    r[j] = -r[j];
	  }
	  long long int r2 = r[j] * p[j];
	  if ( b[j] == 0 ) {
	    b[j] = 1;
	  }else {
	    b[j] = -b[j];
	  }
	  long long int b2 = b[j] * q[j];
	  long long int h = lcm( r2, b2 ) / p[j] + lcm( r2, b2 ) / q[j];
	  
	  r[j] = n + 2;
	  b[j] = n + 2;
	  
	  for ( long long int k = 0; k < n; k++ ) {
	    if ( i == n - 1 ) {
	      cout << h << endl;
	      break;
	    }
	    if ( r[k] == j + 1 ) {
	      r[k] = -h;
	      break;
	    }
	    if ( b[k] == j + 1 ) {
	      b[k] = -h;
	      break;
	    }
	  }
	  break;
	  
	}
	
      }
    }
    
  }
 
  return 0;
 
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  string s; cin >> s;
  cout << s.substr(0, s.size()-8) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
struct UnionFind {
    vector<int> data;
    UnionFind() {}
    UnionFind(int N) : data(N, -1){}
    void unite(int x, int y) {
        x = root(x); y = root(y);
        if(x != y){
            data[x] += data[y];
            data[y] = x;
        }
    }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]);}
    bool same(int a, int b) { return root(a) == root(b);}
};
int L[601], R[601];

int dp[601][301], from[601][301];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, p1, p2;
    while(cin >> N >> p1 >> p2 && (N || p1 || p2)) {
        int P = p1 + p2;
        int x_, y_; string a_;
        UnionFind uf(P * 2);//node_i := if i % 2 (i / 2) is F else (i / 2) is T
        rep(i, N) {
            cin >> x_ >> y_ >> a_;
            --x_; --y_;
            if(a_ == "yes")
              uf.unite(x_ * 2, y_ * 2), uf.unite(x_ * 2 + 1, y_ * 2 + 1);
            else
              uf.unite(x_ * 2, y_ * 2 + 1), uf.unite(x_ * 2 + 1, y_ * 2);
        }
        memset(L, 0, sizeof(L)); memset(R, 0, sizeof(R));
        rep(i, P) {
            int par = uf.root(i * 2);
            if(par % 2) R[par / 2]++; else L[par / 2]++;
        }
        memset(dp, 0, sizeof(dp)); memset(from, 0, sizeof(from));
        int it = 0; dp[0][0] = 1;
        auto upd = [](int& a, int b){
            if(b == 0) return false;
            a = min(2, a + b);
            return true;
        };
        vector<int> group(P, 0);
        int curj; vector<bool> useR(P, false);
        rep(i, P) {
            if(L[i] == 0 && R[i] == 0) continue;
            if(L[i] == R[i]) goto fail;
            ++it; group[it] = i;
            rep(j, p1 + 1) {
                if(upd(dp[it][j + L[i]], dp[it - 1][j]))
                  from[it][j + L[i]] = j;
                if(upd(dp[it][j + R[i]], dp[it - 1][j]))
                  from[it][j + R[i]] = j;
            }
        }
        if(dp[it][p1] != 1) goto fail;
        curj = p1;
        for(int i = it; i >= 1; --i) {
            int temp = curj - from[i][curj];
            if(temp == R[group[i]]) useR[group[i]]= true;
            curj -= temp;
        }
        rep(i, P) {
            int par = uf.root(i * 2);
            if((par % 2 && useR[par / 2]) || (par % 2 == 0 && !useR[par / 2]))
              cout << i + 1 << endl;
        }
        cout << "end" << endl;
        continue;
      fail:
        cout << "no" << endl;
    }
    return 0;
}

Measured memory_bytes: 4572
#include <iostream> 
#include <vector>
using namespace std;
 
int main() {
 
	int n;
	int sum=0;
 
	cin >> n;
	vector<int> x(n, 0);
 
	
	
	for (int i = 0; i < n; i++){
		cin >> x[i];
		if (i % 2 == 0)	sum += x[i];
		else sum -= x[i];
	}
 
	for (int i = 0; i < n; i++){
		if (i != 0)  sum= 2 * x[i-1] - sum;
		else sum = sum;
		cout << sum << " ";
	}
 
 
	
 
	return 0;
}

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

int main(){
  int n,k;cin>>n>>k;
  vector<int> x(n,0);
  REP(i,n) cin>>x.at(i);

  int a,b;
  REP(i,n-k){
    a=x.at(i);
    b=x.at(i+k);
    cout<<(a<b?"Yes":"No")<<endl;
  }
}

Measured memory_bytes: 4052
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

H, W = mi()
A = [input() for i in range(H)]

s = sum(1 for i in range(H) for j in range(W) if A[i][j] == '#')
if s == H+W-1:
    print('Possible')
else:
    print('Impossible')

Measured memory_bytes: 9496
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var d = Input().ToInt();
		
		Array.Sort(d);
		
		Console.WriteLine(d[n/2] - d[n/2-1]);
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 16864
#include<bits/stdc++.h>
using namespace std;
#define int long long int
// #define lli llong int 
#define ld long double
#define ff first
#define ss second
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define pii pair<int, int>
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define scan(n) scanf("%lld",&n)
#define endl "\n"
ld const pi = 3.141592653589793238462;

int const mod = 1e9+7;
int const mod1 = 1e9+6;

int power(int a,int b){
    	int f=1;
    	while(b>0){
		if(b&1){
			f=f*a;
			f%=mod;
		}
		a=a*a;
		a%=mod;
		b=b/2;
	}
	return f;
}

int inverse_mod(int x){
    	return power(x,mod-2);
}

int const N = 2e5+5;



int32_t main(){
	IOS;
	int n,i,j,l;
	cin>>n;
	int a[n];
	int x[3]={0};
	j=0;
	map<int, int> mp;
	for(i=0;i<n;i++){
		cin>>a[i];
		if(mp[a[i]] == 0){
			mp[a[i]]++;
			if(j==3) {
				cout<<"No"<<endl;
				return 0;
			}
			x[j] = a[i];
			j++;
			
		}
		else{
			mp[a[i]]++;
		}
	}
	
	if(n%3){
		if(j==1 && mp[0] == n){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}
	else{
		if(j==3){
			if(x[0] == (x[1]^x[2])){
				if(mp[x[0]] == mp[x[1]] && mp[x[0]] == mp[x[2]]){
					cout<<"Yes"<<endl;
				}
				else{
					cout<<"No"<<endl;
				}
			}
			else{
				cout<<"No"<<endl;
			}
		}	
		else if(j==1){
			if(mp[0] == n){
				cout<<"Yes"<<endl;
			}
			else{
				cout<<"No"<<endl;
			}
		}	
		else if(j==2){
			if(mp[0] == n/3){
				cout<<"Yes"<<endl;
			}
			else{
				cout<<"No"<<endl;
			}
		}
		else{
		 	cout<<"No"<<endl;
		}
	}
 	return 0;
}

/*

1 0 1 0 1




*/

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
using namespace std;
int main() {
	int a = 0, b = 0, c = 0, d[100000], e[100000], f = 0, g = 0, h = 0, count = 0;
	char rikka, toka[100000];
	string saya, homu, kyok, mami,mado[100];
	int manji, nk[26] = {false};
	cin >> saya;
	for (int i = 0; i < saya.length(); i++) {
		if (i % 2 == 0 || i == 0) {
			cout << saya[i];
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  int A;
  cin>>A;
  vector<string> R(A);
  rep(i,A)cin>>R[i];
  int b;
  cin>>b;
  vector<string> B(b);
  rep(i,b)cin>>B[i];
  int ans=0;
  rep(i,A){
    int num=0;
    string word=R[i];
    rep(j,A){
      if(word==R[j])num+=1;
    }
    rep(j,b){
      if(word==B[j])num-=1;
    }
    if(ans<num)ans=num;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  for(int i = 1; 1; i++) {
    if(i * 0.08 >= a && i * 0.08 < a + 1 && i * 0.1 >= b && i * 0.1 < b + 1) {
      cout << i;
      break;
    } else if((i * 0.08) / 1 > a && (i * 0.1) / 1 > b) {
      cout << -1;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
using namespace std;
int s[2][100];
int n,m;
void dfs(int x,int y,int c)
{
    if(x == 1 && y == n - 1)
    {
        if(c > m)m = c;
        return;
    }
    if(x + 1 <= 1)dfs(x + 1,y,c + s[x][y]);
    if(y + 1 < n)dfs(x,y + 1,c + s[x][y]);
}
int main()
{
    cin>>n;
    for(int i = 0;i < n;i ++)
    cin>>s[0][i];
    for(int i = 0;i < n;i ++)
    cin>>s[1][i];
    dfs(0,0,0);
    cout<<m + s[1][n - 1];
}


Measured memory_bytes: 256
N = int(input())
import math
sq_N = int(math.sqrt(N))
ans = 0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
N_divs = make_divisors(N)


for i in range(len(N_divs)): 
    k = N//N_divs[i] - 1
    if k != 0:
        if N//k == N%k:
            ans += k

print(ans)



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

int main() {
  int s;
  string t;

  cin >> s;
  cin >> t;

  if (s % 2 == 0) {
    if (t.substr(0, s/2).compare(t.substr(s/2)) == 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  s:string;
  i:Integer;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(s);

    while True do    
      if (Copy(s,length(s)-6,7)='dreamer') then
        Delete(s,length(s)-6,7)
      else if (Copy(s,length(s)-5,6)='eraser') then
        Delete(s,length(s)-5,6)
      else if (Copy(s,length(s)-4,5)='dream')or(Copy(s,length(s)-4,5)='erase') then
        Delete(s,length(s)-4,5)
      else if s='' then begin
        Writeln('YES');
        break;
      end else begin
        Writeln('NO');
        break;
      end;

    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
const int maxn = 1e3 + 5;
const int INF = 1e9 + 10;
using namespace std;

struct P {
    int to, flag, id;
    P() {}
    P(int t, int f, int i) : to(t), flag(f), id(i) {}
};
int n, m, T, kase = 1;
vector<P> G[maxn];
bool can[maxn][maxn];
int min_flag[maxn], max_flag[maxn];
int ans[200 * maxn];

bool can_arrive(int x) {
    can[x][x] = true;
    queue<int> que; que.push(x);
    while(!que.empty()) {
        int u = que.front(); que.pop();
        for(int i = 0; i < G[u].size(); i++) {
            int to = G[u][i].to;
            if(can[x][to]) continue;
            can[x][to] = true; que.push(to);
        }
    }
}

void dfs(int x, int t, int flag) {
    if(flag == 0 && min_flag[x] != INF) return ;
    if(flag == 1 && max_flag[x] != -INF) return ;
    if(flag == 0) min_flag[x] = min(min_flag[x], t);
    if(flag == 1) max_flag[x] = max(max_flag[x], t);
    for(int i = 0; i < G[x].size(); i++) {
        int to = G[x][i].to;
        dfs(to, t, flag);
    }
}

void solve(int x) {
    for(int i = 1; i <= n; i++) {
        min_flag[i] = INF;
        max_flag[i] = -INF;
    }
    min_flag[x] = max_flag[x] = 0;
    for(int i = 0; i < G[x].size(); i++) {
        int to = G[x][i].to;
        dfs(to, G[x][i].flag, 0);
    }
    for(int i = G[x].size() - 1; i >= 0; i--) {
        int to = G[x][i].to;
        dfs(to, G[x][i].flag, 1);
    }
    for(int i = 0; i < G[x].size(); i++) {
        int flag = 1, to = G[x][i].to;
        if(min_flag[to] == max_flag[to]) flag = 0;
        if(can[to][x] != flag) flag = 0;
        else flag = 1;
        ans[G[x][i].id] = flag;
    }
}


int main() {
    while(scanf("%d %d", &n, &m) != EOF) {
        for(int i = 0; i < maxn; i++) G[i].clear();
        for(int i = 1; i <= m; i++) {
            int u, v, sz;
            scanf("%d %d", &u, &v);
            sz = G[u].size() + 1;
            G[u].push_back(P(v, sz, i));
        }
        memset(can, false, sizeof can);
        for(int i = 1; i <= n; i++) can_arrive(i);
        for(int i = 1; i <= n; i++) solve(i);
        for(int i = 1; i <= m; i++) printf("%s\n", ans[i] ? "same" : "diff");
    }
    return 0;
}


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

#define REP(i,n) for(long long i=0;i<(n);i++)

int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> l(Q), r(Q);
  REP(i, Q) {
    cin >> l[i] >> r[i];
  }
  vector<int> ac;
  ac.push_back(0);
  REP(i, S.size()) {
    if(i == 0) {
      ac.push_back(0);
      continue;
    } else {
      if(S[i] == 'C' && S[i-1] == 'A') {
        ac.push_back(ac[ac.size()-1]+1);
      } else {
        ac.push_back(ac[ac.size()-1]);
      }
    }
  }
  REP(i, Q) {
    int ans = ac[r[i]] - ac[l[i]];
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 2296
#include<iostream>

using namespace std;

int main(){

  int data[5], d[3];

  while(1){

    for(int i = 0; i < 3; i++) d[i] = 0;


    for(int i = 0; i < 5; i++){
      cin >> data[i];
      if(data[0] == 0) return 0;
      if(data[i] == 1) d[0]++;
      else if(data[i] == 2) d[1]++;
      else d[2]++;
    }

      if(d[0] > 0 && d[1] > 0 && d[2] > 0 || d[0] == 5 || d[1] == 5 || d[2] == 5){
	for(int j = 0; j < 5; j++) cout << "3" << endl;
      }else if(d[0] == 0){
	for(int j = 0; j < 5; j++){
	  if(data[j] == 2) cout << "1" << endl;
	  else cout << "2" << endl;
	}
      }else if(d[1] == 0){
	for(int j = 0; j < 5; j++){
	  if(data[j] == 3) cout << "1" << endl;
	  else cout << "2" << endl;
	}
      }else{
	for(int j = 0; j < 5; j++){
	  if(data[j] == 1) cout << "1" << endl;
	  else cout << "2" << endl;
	}
      }
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t X, Y, count = 0;
    cin >> X >> Y;
    while (X <= Y && X > 0){
        X *= 2;
        count++;
    }
    cout << count << endl;

}


Measured memory_bytes: 256
N = int(input())

cset = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
sset = ['a'] * N
def rec(di, usedci):
    if di >= len(sset):
        print(''.join(sset))
        return
    for i in range(usedci+1):
        sset[di] = cset[i]
        rec(di+1, usedci)
    sset[di] = cset[usedci+1]
    rec(di+1, usedci+1)

rec(1, 0)


Measured memory_bytes: 60248
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

#define ll long long

template <typename T>
T _abs(T x) {
	return (x < 0) ? (-x) : (x);
}

const int N = 2e5 + 5;

int n;
ll a[N], s[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", a + i);
		s[i] = s[i - 1] + a[i];
	}
	ll cost = 1e18;
	for (int i = 1; i < n; i++) {
		cost = min(cost, _abs(s[n] - 2 *s[i]));
	}
	printf("%lld\n", cost);
	return 0;
}


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

const int END = -1;
struct StNod
{
  int m_nDept;
  int m_nParnt;
  int m_nLChd;
  int m_nRSib;

  StNod() :
    m_nDept(END), m_nParnt(END), m_nLChd(END), m_nRSib(END)
  { }
};

void fnInput(vector<StNod> &rvoNod)
{
  StNod oNod;
  int nMaxSiz;

  cin >> nMaxSiz;
  rvoNod.resize(nMaxSiz, oNod);

  for (int i = 0; i < nMaxSiz; i++)
  {
    int nParnt, nCCnt, nChd, nBChd = END;
    cin >> nParnt >> nCCnt;
    for (int j = 0; j < nCCnt; j++)
    {
      cin >> nChd;
      rvoNod[nChd].m_nParnt = nParnt;
      if (nBChd != END) rvoNod[nBChd].m_nRSib = nChd;
      if (!j)          rvoNod[nParnt].m_nLChd = nChd;
      nBChd = nChd;
    }
  }
}

void fnSetDepth(vector<StNod> &rvoNod, int nx, int nDept)
{
  rvoNod[nx].m_nDept = nDept;
  
  if (rvoNod[nx].m_nRSib != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nRSib, nDept);

  if (rvoNod[nx].m_nLChd != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nLChd, nDept + 1);
}

void fnRtdTree(vector<StNod> &rvoNod)
{
  int nx = 0, nDept = 0;
  while (rvoNod[nx].m_nParnt != END)
    nx = rvoNod[nx].m_nParnt;

  fnSetDepth(rvoNod, nx, nDept);
}

void fnResult(const vector<StNod> &cnrvoNod)
{
  for (int i = 0; i < cnrvoNod.size(); i++)
  {
    if (cnrvoNod[i].m_nDept == END)  break;
    cout << "node " << i << ": parent = " << cnrvoNod[i].m_nParnt << ", depth = " << cnrvoNod[i].m_nDept;

    if (!cnrvoNod[i].m_nDept)            cout << ", root, ";
    else if (cnrvoNod[i].m_nLChd == END) cout << ", leaf, ";
    else                                 cout << ", internal node, ";

    cout << "[";
    if (cnrvoNod[i].m_nLChd != END)
    {
      int nx = cnrvoNod[i].m_nLChd;
      cout << nx;
      while (cnrvoNod[nx].m_nRSib != END)
      {
        cout << ", " << cnrvoNod[nx].m_nRSib;
        nx = cnrvoNod[nx].m_nRSib;
      }
    }
    cout << "]" << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<StNod> voNod;

  fnInput(voNod);
  fnRtdTree(voNod);
  fnResult(voNod);
  return 0;
}

Measured memory_bytes: 5748
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
const ll  longinf = 1LL<<60;
const int mod=1000000007;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
int n,m,a[8][8],visit[8],cnt;
void dfs(int x,int y){
  if(y==0)
    cnt++;
  else{
    rep(i,n){
      if(a[x][i]==1&&visit[i]==0){
        visit[i]=1;
        dfs(i,y-1);
        visit[i]=0;
        }
      }
    }
  }
int main(){
  cin>>n>>m;
  int l[m],r[m];
  rep(i,n)rep(j,n)a[i][j]=0;
  rep(i,m){
    cin>>l[i]>>r[i];
    a[l[i]-1][r[i]-1]=1;
    a[r[i]-1][l[i]-1]=1;
    }
  rep(i,n)visit[i]=0;
  visit[0]=1;
  cnt=0;
  dfs(0,n-1);
  cout<<cnt<<endl;
  return 0;
  }

Measured memory_bytes: 256
#include<stdio.h>
#include<cstdlib>

void CountingSort(int*, int, int);
int Partition(int*, int, int);

void Swap(int*, int*);

int main(){
    int i, n, *A, mid;
    
    scanf("%d", &n);
    A = (int *)malloc(sizeof(int) * n + 1);
    for (i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    mid = Partition(A, 0, n-1);
    
    for (i = 0; i < n-1; i++) {
        if (i != mid) {
            printf("%d", A[i]);
        }else{
            printf("[%d]", A[mid]);
        }
        printf(" ");
    }
    printf("%d\n", A[n-1]);
    
    return 0;
}


void CountingSort(int* A, int a, int b){
    
}

int Partition(int* A, int p, int r){
    int x = A[r], i = p-1, j;
    
    for (j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            Swap(&A[i], &A[j]);
        }
    }
    Swap(&A[i+1], &A[r]);
    
    return i+1;
}

void Swap(int *x, int *y){
    int tmp;
    tmp = *y;
    *y = *x;
    *x = tmp;
}



Measured memory_bytes: 3152
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<utility>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;


int main() {
	int n,a=0;
	cin>>n;
	vector<int> vec(n);
	rep0(i,n)cin >> vec[i];
	sort(all(vec));
	cout<< vec[n/2]-vec[n/2-1];
	
}

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

int main() {
	int n; 
	cin>>n;
	int digit = n%10;
	if(digit == 3){
		cout<<"bon";
	}
	else if(digit == 0 || digit ==1 || digit == 6 || digit == 8){
		cout<<"pon";
	}
	else cout<<"hon";
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 3e3+1;
const int mod = 998244353;
ll dp[upperlimit];
int a[upperlimit];
int main() {
//	freopen(".in","r",stdin);freopen(".out","w",stdout);
	int n,s;
	sd(n);sd(s);
	for(int i = 1; i <= n; i++) sd(a[i]);
	dp[0]=1;
	for(int i = 1; i <= n; i++){
		for(int j = s; j >= a[i]; j--){
			dp[j]*=2;dp[j]+=dp[j-a[i]];
			dp[j]%=mod;
		}
		for(int j = 0; j < a[i]; j++){
			dp[j]*=2;dp[j]%=mod;
		}
	}
	plld(dp[s]);
	return 0;
}

Measured memory_bytes: 3788
n = gets.to_i
ans = 0
(1..n).each do |i|
    next if i.even?
    count = 0
    (1..n).each do |k|
        if i%k == 0
            count += 1
        end 
    end 
    if count == 8
        ans += 1
    end 
end
puts ans

Measured memory_bytes: 1788
#define _GLIBCXX_DEBUG

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

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//bitsearch
#define BITSEARCH(bit, n) for (int bit = 0; bit < (1<<n); ++bit)
#define isOne(bit, i) bit & (1<<i)


//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back


#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

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

//pair
#define fir first
#define sec second
#define mp make_pair

//types
#define ll long long
#define vec vector
#define cord2d pair<int,int>
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(long long a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(char a){ cout << a << endl; }
void print(double a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T = int>
void print(vec<T> v){ cout << v << endl; }

template <class T = int>
void print2dVec(vec<vec<T>> v2d){for(vec<T> v: v2d) {print(v);}}

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

//maths
int factorial(int k){ int sum = 1; for (int i = 1; i <= k; ++i) { sum *= i; } return sum; }
int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

void Main() {
    //code here
    int n = gi, l = gi;
    vec<int> appfls;
    REP(i,n) appfls.add(l+i);
    //print(appfls);
    sort(ALL(appfls), [](int a, int b) {return abs(a) < abs(b);});
    int res = 0;
    OneToN(i, n-1) res += appfls[i];
    print(res);
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  string S;
  cin >> S;
  bool existN=false, existW=false, existS=false, existE=false;
  for (int i=0; i<S.size(); i++) {
    if (S[i]=='N') {
      existN = true;
      break;
    }
  }
  for (int i=0; i<S.size(); i++) {
    if (S[i]=='W') {
      existW = true;
      break;
    }
  }
  for (int i=0; i<S.size(); i++) {
    if (S[i]=='S') {
      existS = true;
      break;
    }
  }
  for (int i=0; i<S.size(); i++) {
    if (S[i]=='E') {
      existE = true;
      break;
    }
  }
  if ((existN!=existS)||(existW!=existE)) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
N = int(input())
x = [0 for _ in range(N)]; y = [0 for _ in range(N)]
for i in range(N):
    x[i], y[i] = map(int, input().split())

def dist(x1, x2, y1, y2):
    return ((x1-x2)**2+(y1-y2)**2)**(1/2)

def factorial(n):
    if n==1:
        return 1
    else:
        return n*factorial(n-1)

total = 0
for i in range(N):
    for j in range(i+1, N):
        total += dist(x[i], x[j], y[i], y[j])

line_num = N*(N-1)/2
path_num = (N-1)*factorial(N)/line_num

print(path_num*total/factorial(N))

Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
    int N;
    scanf("%d",&N);
    double x;
    char u[3];
    double sum = 0;
    for(int i=0;i<N;i++){
        scanf("%lf %s",&x,u);
        if(u[0]=='B'){
            x = x*380000;
            //printf("%lf",x);
        }
        sum += x;
    }
    printf("%lf",sum);
    return 0;
}

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

using ll = long long int;

const ll MAX_N = (ll)(5000 + 5);
const ll MAX_K = (ll)(5000 + 5);

ll n, k;
ll a[MAX_N];
ll aexclude[MAX_N];

bool dp[5000 + 5];

ll ans = 0;

bool makeable(ll exc) {
  for (ll j = 0; j < k; ++j) dp[j] = false;

  dp[0] = true;

  /*
  cout << a[exc] << endl;
  for (ll i = 0; i < k; ++i) {
    printf("%2lld ", i);
  }
  cout << endl;
  */

  for (ll i = 0; i < n; ++i) {
    if (i == exc) continue;
    for (ll j = k - 1; j >= 0; --j) {
      if (j - a[i] >= 0 && dp[j - a[i]]) dp[j] = true;
    }

    /*
    for (ll i = 0; i < k; ++i) {
      printf("%2lld ", dp[i]);
    }
    cout << endl;
    */
  }

  ll left = max((ll)(0), k - a[exc]);

  /*
  cout << a[exclude] << endl;
  for (ll i = 0; i < k; ++i) {
    printf("%2lld ", i);
  }
  cout << endl;

  for (ll i = 0; i < k; ++i) {
    printf("%2lld ", dp[i]);
  }
  cout << endl;
  cout << endl;
  */

  for (ll i = left; i < k; ++i) {
    if (dp[i]) {
      // cout << a[exclude] << "_" << i << endl;
      return true;
    }
  }

  return false;
}

int main(void) {
  // Here your code !
  scanf("%lld %lld", &n, &k);

  for (ll i = 0; i < n; ++i) {
    scanf("%lld", &(a[i]));
  }

  sort(a, a + n);

  /*
  for (int i = 0; i < n; ++i) {
    if (!makeable(i)) ans += 1;
  }
  */

  ll l = 0;
  ll r = n;

  if (makeable(0)) {
    ans = 0;
    printf("%lld\n", ans);
    return 0;
  }

  while (abs(l - r) > 1) {
    // cout << l << "_" << r << endl;

    ll mid = (l + r) / 2;

    if (makeable(mid)) {
      r = mid;
    }
    else l = mid;
  }

  ans = l + 1;

  // cout << l << endl;

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

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    table = [1]*(n+1)
    
    for i in range(2, n+1):
        for j in range(i, n+1, i):
            table[j] += 1
    
    ans = 0
    for i in range(n+1):
        ans += table[i]*i
    
    print(ans)
    
    
if __name__ == "__main__":
    main()



Measured memory_bytes: 151700
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	int X[100] = { 0 };
	cin >> a;
	if (a < 1200) {
		cout << "ABC";
	}
	else if (a < 2800) {
		cout << "ARC";
	}
	else {
		cout << "AGC";
	}
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(ll i = 0; i<n; i++)
#define rep_s(i, start, n) for(ll i= start;  i<n; i++)
#define rep_down(i, n) for(ll i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(ll i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()
#define print(ans) cout << ans << endl;
#define MOD 1000000007
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll keta_num(ll num){
  ll total = 0;
  while(num){
    num /= 10;
    total++;
  }
}


ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

ll fibonacchi(ll num){
  ll f0 = 0, f1 = 1, f2;
  ll count = 0;
  while(count<num){
    f2 = f0+f1;
    f0 = f1;
    f1 = f2;
    count++;
  }
  return f2;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, G, K,L, W, H, P, Q, R, V, X, Y;
  string S, T;
  cin >> S;
  if (S =="ARC") cout << "ABC" << endl;
  else cout << "ARC" << endl;



}


Measured memory_bytes: 3624