akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define SZ(x) ((ll)(x).size())
#define pb push_back
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;

const int MOD = 1e9 + 7;

using P = pair<ll,ll>;
V<> fib(90, 1);
VV<P> worst(85);

void preparation(){
    for(int i = 2; i < 90; i++) fib[i] = fib[i-1] + fib[i-2];
    worst[0].pb({1, 2}); 
    REP(i, 84){
        REP(j, SZ(worst[i])){
            P p = worst[i][j];
            ll a = p.first, b = p.second, c = a + b;
            worst[i + 1].pb({b, c});
            if(!j) worst[i + 1].pb({c, b + 2 * a});
        }
    }
}

ll x, y;
void solve(){
    scanf("%lld%lld", &x, &y);
    if(x > y) swap(x, y);
    if(y <= 2){
		printf("1 %d\n", x*y);
        return;
    }
    ll a = 0;
    while(fib[a + 1] <= x and fib[a + 2] <= y) a++;
    if(a == 1){
        printf("%d %d\n", 1, (x%MOD*y)%MOD);
        return;
    }
    ll res = 0;
    for(auto &p : worst[a - 1]){
        if(p.first > x or p.second > y) continue;
        res++;
        res = (res + (y - p.second) / p.first) % MOD;
        if(p.second > x or p.first > y) continue;
        res++;
    }
    printf("%d %d\n", a, res%MOD);
}

int q;
int main(){
    ios;
    preparation();
    scanf("%d", &q);
    while(q--) solve();
}

Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n;
    cin >> n;
    ll a[n + 1] = {};
    rep(i, 1, n + 1) {
        cin >> a[i];
    }

    int num[n + 1] = {};
    for (int i = n; i >= 1; i--) {
        int sum = 0;
        for (int j = i; j <= n; j += i) {
            sum += num[j];
        }
        if (sum % 2 != a[i]) num[i]++;
    }

    int m = 0;
    rep(i, 1, n + 1) m += num[i];
    cout << m << endl;
    rep(i, 1, n + 1) {
        if (num[i]) cout << i << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL A, B;
LL gcd(LL x, LL y){
    if(y == 0)return x;
    else return gcd(y, x % y);
}
int main(){
    cin>>A>>B;
    LL g = gcd(A, B);
    int ans = 1;
    //printf("g=%lld\n", g);
    LL tmp = g;
    for(int i = 2;1LL * i * i <= tmp; i++){
        if(g % i != 0)continue;
        //printf("i=%d\n", i);
        ans++;
        while(g % i == 0)g /= i;
    }
    if(g != 1)ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int n;
vector<int> e[100005];
int path[100005], cntP;
int warna[100005];
bool udah;

void dfs(int cur, int prv)
{
   if(udah) return;
   path[cntP++] = cur;
   if(cur == n) { udah=true; return; }
   for(int i=0;i<e[cur].size();i++)
   {
      int nxt=e[cur][i];
      if(nxt==prv) continue;
      dfs(nxt, cur);
      if(udah) return;
   }
   if(udah) return;
   path[cntP--] = cur;
}

void dfs2(int cur, int prv, int col)
{
   if(col==1 && warna[cur]==2) return;
   else if(col==2 && warna[cur]==1) return;
   warna[cur]=col;
   for(int i=0;i<e[cur].size();i++)
   {
      int nxt=e[cur][i];
      if(nxt==prv) continue;
      dfs2(nxt, cur, col);
   }
}

int main()
{
   scanf("%d", &n);
   for(int i=0;i<n-1;i++)
   {
      int a, b; scanf("%d%d", &a, &b);
      e[a].push_back(b);
      e[b].push_back(a);
   }

   dfs(1, -1);
   //printf("cnt %d\n", cntP);
   //1 = black, 2 = white
   warna[1]=1; warna[n]=2;
   int curW=cntP-2;
   for(int i=1;i<cntP-1;i++)
   {
      if(warna[path[i]]!=0) break;
      warna[path[i]]=1;
      if(i<curW && warna[path[curW]]==0) warna[path[curW--]]=2;
   }

   //color allll
   dfs2(1, -1, 1);
   dfs2(n, -1, 2);

   int black=0, white=0;
   for(int i=1;i<=n;i++)
   {
      if(warna[i]==1) black++;
      else white++;
      //printf("yay %d %d\n", i, warna[i]);
   }
   //printf("%d %d\n", black, white);
   if(black>white) printf("Fennec\n");
   else printf("Snuke\n");
   return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll ans = -InfLL;
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ans = max(ans, a * c);
	ans = max(ans, a * d);
	ans = max(ans, b * c);
	ans = max(ans, b * d);



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

Measured memory_bytes: 3632
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 0;
		if(a >= b){
			ans += a;
			a--;
		}else{
			ans += b;
			b--;
		}
		if(a >= b){
			ans += a;

		}else{
			ans += b;
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int X, Y;
    cin >> X >> Y;
    cout << (X % Y != 0 ? X : -1) << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int a;
	cin >> a;
	cout << a + a * a + a * a * a << '\n';
}

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

int main(){
	int n;
	cin>>n;
	int arr[n+2]={0};
	for(int i=1; i<=n; i++) cin>>arr[i];
	int localmax = arr[1];
	int localmin = arr[0];
	long long ret = 0;
	for(int i=1; i<=n+1; i++){
		if(arr[i-1]==arr[i]) continue;
		else if(arr[i]>arr[i-1]) localmax = arr[i];
		else{
			ret+=(localmax-localmin);
			localmax = arr[i];
			localmin = arr[i];
		}
	}
	cout<<ret;
}

Measured memory_bytes: 3592
use std::io::Read;

fn z_algorithm(s: &Vec<char>) -> Vec<usize> {
    let n = s.len();
    let mut a = vec![0; n];
    a[0] = n;
    let mut i = 1;
    let mut j = 0;
    while i < n {
        while i + j < n && s[j] == s[i + j] {
            j += 1;
        }
        a[i] = j;
        if j == 0 {
            i += 1;
            continue;
        }
        let mut k = 1;
        while i + k < n && k + a[k] < j {
            a[i + k] = a[k];
            k += 1;
        }
        i += k;
        j -= k;
    }
    a
}

fn calc(x: usize, state: &mut [usize], dp: &mut [usize], z: &[usize], n: usize, m: usize) -> usize {
    if state[x] == 1 {
        return std::usize::MAX / 2;
    }
    if state[x] == 2 {
        return dp[x];
    }
    state[x] = 1;
    dp[x] = if z[x] >= m {
        let next = (x + m) % n;
        calc(next, state, dp, z, n, m) + 1
    } else {
        0
    };
    state[x] = 2;
    return dp[x];
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let s: Vec<char> = it.next().unwrap().chars().collect();
    let t: Vec<char> = it.next().unwrap().chars().collect();
    let mut a = vec![];
    while a.len() < 2 * std::cmp::max(s.len(), t.len()) {
        a.append(&mut s.clone());
    }
    let mut b = t.clone();
    b.push('#');
    b.append(&mut a.clone());
    let z = z_algorithm(&b).split_off(t.len() + 1);
    let n = s.len();
    let m = t.len();
    let mut state = vec![0; n];
    let mut dp = vec![0; n];
    for i in 0..s.len() {
        if state[i] == 2 {
            continue;
        }
        if std::usize::MAX / 2 <= calc(i, &mut state, &mut dp, &z, n, m) {
            println!("-1");
            return;
        }
    }
    let ans = *dp.iter().max().unwrap();
    println!("{}", ans);
}

fn main() {
    run();
}


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

using namespace std;

const int INF = 0x7f7f7f7f;
const int H = 205;
const int HH = H + H;

vector <int> _e[HH], _er[HH], *e = _e + H, *er = _er + H;
int _in[HH], _out[HH], *in = _in + H, *out = _out + H;
bool _skip[HH], *skip = _skip + H;

int main()
{
  int n, h, a, b, c, d;
  scanf("%d %d", &n, &h);
  for (int i = 0; i < n; ++i) {
    scanf("%d %d %d %d", &a, &b, &c, &d);
    int u = (c == 0 ? -a : c);
    int v = (d == 0 ? b : -d);
    e[u].push_back(v);
    er[v].push_back(u);
  }
  for (int i = -h; i <= h; ++i) {
    out[i] = (int)e[i].size();
    in[i] = (int)er[i].size();
    if (i < 0 && in[i] > out[i]) {
      puts("NO");
      return 0;
    }
    if (i > 0 && in[i] < out[i]) {
      puts("NO");
      return 0;
    }
    if (in[i] == 0 && out[i] == 0)
      skip[i] = true;
  }
  for (int i = -h; i <= h; ++i) {
    if (skip[i])
      continue;
    vector <int> de;
    de.push_back(i);
    int top = 0;
    while (top < (int)de.size()) {
      int u = de[top];
      for (int j = 0; j < (int)e[u].size(); ++j) {
        if (!skip[e[u][j]]) {
          de.push_back(e[u][j]);
          skip[e[u][j]] = true;
        }
      }
      for (int j = 0; j < (int)er[u].size(); ++j) {
        if (!skip[er[u][j]]) {
          de.push_back(er[u][j]);
          skip[er[u][j]] = true;
        }
      }
      ++top;
    }
    bool ans = false;
    for (int j = 0; j < (int)de.size(); ++j) {
      if (de[j] < 0 && in[de[j]] < out[de[j]]) {
        ans = true;
        break;
      }
    }
    if (!ans) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}

Measured memory_bytes: 1792
N,M=map(int,input().split())

H=[0]+list(map(int,input().split()))

J={x:[] for x in range(1,N+1)}

for i in range(M):
    a,b=map(int,input().split())
    J[a].append(b)
    J[b].append(a)

S=0
for x in J:
    f=1
    for y in J[x]:
        if H[x]<=H[y]:
            f=0
    S+=f

print(S)


Measured memory_bytes: 95740
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
int main(){
  long N;
  cin>>N;
  vector<long> a(N),b(N),c(N);
  rep(i,N) {
    cin >> a.at(i);
  }
  rep(i,N) {
    cin >> b.at(i);
  }
  rep(i,N) {
    cin >> c.at(i);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  long ans=0;
  rep(i,N) {
    long d=b.at(i);
    long A=lower_bound(a.begin(),a.end(),d)-a.begin();
    long C=N-(upper_bound(c.begin(),c.end(),d)-c.begin());
    
    ans = ans+A*C;
    
  }
 
  

    cout<<ans<<endl;
  
}
  

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(a+b==15)cout<<'+'<<endl;
    else if(a*b==15)cout<<'*'<<endl;
    else cout<<'x'<<endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  
  int N,D;
  cin>>N>>D;
  int g[11][11];
  
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin>>g[i][j];
    }
  }
  ll count=0;
  for(int i; i<N;i++){
    for(int j=N-1;j>i;j--){
      ld ans=0;
      for(int l=0;l<D;l++){
        
        ans+=std::pow((g[i][l]-g[j][l]),2);
      }
      ld pp=std::pow(ans,0.5);
      if(ceil(pp)==floor(pp))
        count++;
    }
  }
  cout<<count<<endl;
  
}
  

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
  int n,h[100005];
  int dp[100005]={};

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);

  for(int i=2;i<n;i++){
    dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
  }
  
  cout<<dp[n-1]<<"\n";

  return 0;
}


Measured memory_bytes: 1024
l, r = map(int, input().split())
m = 2019
if r - l >= 673:
    print(0)
else:
    ans = 2018
    for i in range(l, r):
        for j in range(i+1, r+1):
            ans = min(ans, (i*j)%m)
        if ans <= 2:
            break
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}

const int MAXN = 1e5 + 100;

int n;
vector<int> adj[MAXN];
LL g[MAXN];

void go(int r, int p) {
	g[r] = 0;
	int cnt = 0;
	for(auto &elem: adj[r]) {
		if(elem != p) {
			go(elem, r);
			cnt++;
		}
	}
	if(cnt == 0) {
		g[r] = 0;
	} else if(cnt == 1) {
		for(auto &elem: adj[r]) {
			if(elem != p) {
				g[r] = g[elem] + 1;
			}
		}
	} else {
		for(auto &elem: adj[r]) {
			if(elem != p) {
				g[r] = g[r] ^ (g[elem] + 1);
			}
		}
	}
}

int main() {
  ios_base::sync_with_stdio(false);
	int a, b;
	cin >> n;
	for(int i = 1; i < n; i++) {
		cin >> a >> b;
		adj[a].push_back(b); adj[b].push_back(a);
	}
	go(1, 0);
	if(g[1] > 0) cout << "Alice" << endl;
	else cout << "Bob" << endl;
  return 0;
}


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

#include<bits/stdc++.h>

using namespace std;

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

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

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

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class C100To105 {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int x; cin >> x;
      vector<bool> dp(x+1);
      dp[0] = true;
      for(int i=100; i<=105; i++) {
        for(int j=0; j+i<=x; j++) {
          if (dp[j]) {
            dp[j+i] = true;
            debug(i+j);
          }
        }
      }


      cout << (dp[x] ? 1 : 0) << endl;
    }
};

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

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
  int n;
  char str[105];
  scanf("%d",&n);
  scanf("%s",str);
  if(n%2!=0){
    printf("No");
  }
  else{
    for(int i=0;i<n/2;i++)
    {
      if(str[i]!=str[n/2+i])
      {
        printf("No");
        return 0;
      }
    }
    printf("Yes");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        int N, A, T, ans = 0, tmp = 10000000000;
        cin >> N >> T >> A;
        vector<int> vec(N);
        rep(i, N) cin >> vec[i];
        int cnt;
        rep(i, N)
        {
                cnt = T * 1000 - vec[i] * 6;
                int ab = -A * 1000 + cnt;
                if (ab < 0)
                        ab = -ab;
                if (ab <= tmp)
                {
                        ans = i;
                        tmp = ab;
                }
        }

        cout << ans + 1 << endl;

        return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,m;
  int i,j,k;
  int mat[100][100]={{}};
  int ve[100]={};
  cin >> n >> m;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      cin >> mat[i][j];
    }
  }
  for(j=0;j<m;j++) cin >> ve[j];
  for(i=0;i<n;i++){
    int x=0;
    for(j=0;j<m;j++) x+=mat[i][j]*ve[j];
    cout << x << endl;             
  }
   
  return 0;
}


Measured memory_bytes: 3144
from collections import deque
n, m = map(int, input().split())
list_MAP = [[]for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    list_MAP[a-1].append(b)
    list_MAP[b-1].append(a)

set_A = {1}
ans = [pow(10, 10)]*n
q = deque([1])
while True:
    if len(q) == 0:
        break
    num = q.popleft()
    l = list_MAP[num-1]
    for i in l:
        if i not in set_A:
            ans[i-1] = num
            set_A.add(i)
            q.append(i)


if ans.count(pow(10, 10)) > 1 :
    print("No")
else:
    print("Yes")
    for i in range(1, n):
        print(ans[i])


Measured memory_bytes: 40112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		long a, b, c, count = 0;
		a = Long.parseLong(strArr[0]);
		b = Long.parseLong(strArr[1]);
		c = Long.parseLong(strArr[2]);
		for(long i = a;i <= b;i++){
			count += (c % i == 0)?1:0;
		}
		System.out.printf("%d%n", count);
	}
}

Measured memory_bytes: 17052
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n;cin>>n;
    cout<<"ABC"<<n<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

typedef long long ll;
const int N=100009;
const int M=200009;

int n,m;
int to[M<<1],nxt[M<<1],beg[N],tot;
int col[N],cnt,flag,si,bi,nbi;

inline void add(int u,int v)
{
	to[++tot]=v;
	nxt[tot]=beg[u];
	beg[u]=tot;
}

inline void dfs(int u)
{
	cnt++;
	for(int i=beg[u];i;i=nxt[i])
		if(col[to[i]]==-1)
		{
			col[to[i]]=col[u]^1;
			dfs(to[i]);
		}
		else if(col[to[i]]!=col[u]^1)
			flag=1;
}

int main()
{
	if(fopen("vj.in","r"))
	{
		freopen("vj.in","r",stdin);
		freopen("vj.out","w",stdout);
	}

	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		add(u,v);add(v,u);
	}
	
	memset(col,-1,sizeof(col));

	for(int i=1;i<=n;i++)
		if(col[i]==-1)
		{
			cnt=flag=0;
			col[i]=0;
			dfs(i);
			if(cnt==1)si++;
			else if(flag)nbi++;
			else bi++;
		}

	ll ans=0;
	ans=1ll*si*si+2ll*si*(n-si);
	ans+=1ll*nbi*nbi+2ll*bi*nbi;
	ans+=2ll*bi*bi;

	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  ll ans = 1;
  while (n >= pow(k, ans)) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::slice::*;

fn main() {
    let (r, w, e) = (stdin(), stdout(), stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    // =============================================== //
    let n: usize = io.read();

    let a = io.readn::<isize>(n);
    let mut dp = vec![vec![0isize; 3030]; 3030];
    for s in 2..n + 2 {
        for j in s..n + 2 {
            let k = j - s + 1;
            if (n - (j - k)) % 2 == 0 {
                dp[k][j] = max(dp[k][j - 1] + a[j - 2], dp[k + 1][j] + a[k - 1]);
            } else {
                dp[k][j] = min(dp[k][j - 1] - a[j - 2], dp[k + 1][j] - a[k - 1]);
            }
        }
    }
    io.writeln(dp[1][n + 1]);
}

// IO
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug ) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
}


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

int main(int argc, const char * argv[]) {
    
    int n;
    int sen,hyaku,juu,iti;
    int a;
    
    cin >> n;
    
    for(int i=1;i<11;i++){
        a=n-(i*1000);
        if(a<0){
            sen=i-1;
            break;
        }
    }
    n=n-(sen*1000);
    
    for(int i=1;i<11;i++){
        a=n-(i*100);
        if(a<0){
            hyaku=i-1;
            break;
        }
    }
    n=n-(hyaku*100);
    
    for(int i=1;i<11;i++){
        a=n-(i*10);
        if(a<0){
            juu=i-1;
            break;
        }
    }
    n=n-(juu*10);
    
    for(int i=1;i<11;i++){
        a=n-i;
        if(a<0){
            iti=i-1;
            break;
        }
    }
    
    if(sen==hyaku && sen==juu){
        cout << "Yes" << endl;
    }
    else if(hyaku==juu && hyaku==iti){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
struct Edge { LL to, cost; };
double h, w, n, m, s, k, sum, ans = 0, pos[3][2], vec[3], a[1000000],r;
string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
int main() {
	rep(i,3) {
		cin >> pos[i][0] >> pos[i][1];
	}
	rep(i, 3) {
		vec[i] = sqrt(pow(pos[i][0] - pos[(i + 1) % 3][0], 2) + pow(pos[i][1] - pos[(i + 1) % 3][1], 2));
	}
	m = (vec[0] + vec[1] + vec[2]) / 2;
	s = sqrt(m*(m - vec[0])*(m - vec[1])*(m - vec[2]))*2;
	r = s / (m * 2);
	m = max(vec[0], max(vec[1], vec[2]));
	double high = m, low = 0, middle;
	rep(i, 100) {
		middle = (high + low) / 2;
		if ((m*(r-middle) / r) >= middle * 2) 
			low = middle;
		else high = middle;
	}
	printf("%.15f\n", middle);
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		long ans = 0;
		int EA = 0;
		int SB = 0; //xxxxA+Bxxx has one AB occurrence
		int both = 0;
		int N = I.nextInt();
		for (int i = 0; i < N; i++) {
			String S = I.next();
			for (int j = 0; j < S.length()-1; j++) {
				if (S.charAt(j)=='A'&&S.charAt(j+1)=='B') ans++;
			}
			if (S.charAt(0)=='B'&&S.charAt(S.length()-1)=='A') both++;
			else if (S.charAt(0)=='B') SB++;
			else if (S.charAt(S.length()-1)=='A') EA++;
		}
		int min = Math.min(SB, EA);
		int max = Math.max(SB,EA);
		if (max==0&&min==0&&both>0) {
			both--; //No previous bonds to optimize with (x BAs yield x-1 ABs when added)
			ans+=both;
		}else {
			max-=min;
			if (max>=both) ans+=both; //BA can be used as a complement to end A or start B
			else {
				ans+=max;
				both-=max;
				ans+=both;
			}
		}
		ans+=min;
		O.pln(ans);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}



Measured memory_bytes: 30088
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        k: usize,
        (a,b): (usize, usize)
    };

    for x in a..=b {
        if x % k == 0 {
            println!("OK");
            return;
        }
    }

    println!("NG");
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll n, a, b; cin >> n >> a >> b;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  ll res = 0;
  for (ll i = 1; i < n; i++) {
    res += min(a*(v.at(i)-v.at(i-1)), b);
  }
  cout << res << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char** argv)
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);

	if (a < b && b < c)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

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

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  
  if (x <= a*a*b/2) {
    double wv = x/a;
    double r_h = 2*wv/b;
    double answer = atan(b / r_h) / (2 * 3.14159265358979) * 360;
    cout << setprecision(12) << answer << endl;
  } else {
    x = a*a*b - x;
    double wv = x/a;
    double r_h = 2*wv/a;
    double answer = atan(r_h / a) / (2 * 3.14159265358979) * 360;
    cout << setprecision(12) << answer << endl;
  }

  return 0;
}

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

#define mod 1000000007
int main()
{
   long int n,i;
   cin>>n;
   
   long int A[n];
   long long pre=0;
   for(i=0;i<n;++i)
   {
       cin>>A[i];
       pre+=A[i];
   }
    
   
   long long ans=0;
   for(i=0;i<n;++i)
   {  
       pre=pre-A[i];
      long long temp=(((pre%1000000007)*(A[i]%1000000007))%1000000007);
      
      ans=(ans%1000000007+temp%1000000007)%1000000007;
   }
   
   cout<<ans<<endl;
   
}

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

namespace ConsoleApplicationABC98D_ {
    class Program {
        static void Main(string[] args) {
            String line;
            line = Console.ReadLine();
            String[] var = line.Split(new char[] { ' ' });
            int N = int.Parse(var[0]);
            int K = int.Parse(var[1]);
            int Q = int.Parse(var[2]);
            line = Console.ReadLine();
            String[] Astr = line.Split(new char[] { ' ' });
            int[] A = new int[N];
            for (int i = 0; i < N; i++) { A[i] = int.Parse(Astr[i]); }


            int[] A0 = (int[])A.Clone();
            Array.Sort(A0);
            int minXmY = A0[A0.Length - 1] - A0[0];

            var A3 = new List<int>();
            var A2 = new List<int>();
            for (int i = N - Q; i >= 0; i--) {
                int Y = A0[i];
                A3.Clear();
                A2.Clear();
                for (int j = 0; j < N; j++) {
                    if (A[j] >= Y) {
                        A2.Add(A[j]);
                    } else {
                        if (A2.Count >= K) {
                            A2.Sort();
                            A3.AddRange(A2.GetRange(0, A2.Count - K + 1));
                        }
                        A2.Clear();
                        if (j >= N - K) { break; }
                    }
                }
                if (A2.Count >= K) {
                    A2.Sort();
                    A3.AddRange(A2.GetRange(0, A2.Count - K + 1));
                }
                if (A3.Count >= Q) {
                    A3.Sort();
                    int XmY = A3[Q - 1] - Y;
                    if (minXmY > XmY) { minXmY = XmY; }
                }
            }

            Console.WriteLine(minXmY.ToString());
        }
    }
}


Measured memory_bytes: 25568
#include <iostream>

using namespace std;

int main() {
	int N, sum = 0, t = 0;
	cin >> N;
	int a[N], c[N-1];
	for (int i = 0; i<N; ++i) cin >> a[i];
	for (int i = 0; i<N; ++i) {
		cin >> t;
		sum+=t;
	}
	for (int i = 0; i<N-1; ++i) {
		cin >> c[i];

	}
	for (int i = 1; i<N; ++i) {
		if (a[i]-1 == a[i-1]) {
			sum+=c[a[i-1]-1];
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>

void print(vector<int> arr){for(auto i:arr){printf("%d ",i);}cout<<endl;}

int main()
{
    int n;scanf("%d",&n);
    vector<int> a(n),b(n),c(n);
    for(auto &i:a){scanf("%d",&i);}
    for(auto &i:b){scanf("%d",&i);}
    int x,y,count=1;
    for(int i=1;i<=n;i++){c[i-1]=i;}
    if(a==c){x=1;}
    if(b==c){y=1;}
    // if(!next_p
    while(next_permutation(c.begin(),c.end())){
        count++;
        if(a==c){x=count;}
        if(b==c){y=count;}
    }
    printf("%d",abs(x-y));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 





int main()
{
     int n;
     cin>>n;
     int a[n+1];
     for(int i=1;i<=n;i++)cin>>a[i];
     int res[n+1];
     for(int i=n;i>0;i--){
          int t=0;
          for(int j=i+i;j<=n;j+=i){
               t+=res[j];
          }
          if(t%2!=a[i]){
               res[i]=1;
          }
          else{
               res[i]=0;
          }
     }
     int ct=0;
     for(int i=1;i<=n;i++)if(res[i]==1)ct++;
     cout<<ct<<endl;
     for(int i=1;i<=n;i++){
          if(res[i]==1)cout<<i<<" ";
     }
     
}




































Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const string nl="\n";
const ll MOD=1000000007;
const ll INF=1e5+5;
vector<ll> graph[100005];
ll n,m;
int dis[100005]={};
ll dfs(ll x){
	if(dis[x])return dis[x];
	ll z = 0;
	for(int i=0;i<graph[x].size();i++){
		z = max(dfs(graph[x][i]),z);
	}
	dis[x]= z+1;
	return dis[x];
}

int main(){
    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    cin>>n>>m;
    for(int i=0;i<m;i++){
    	ll x,y;
    	cin>>x>>y;
    	graph[x].push_back(y);
    }	
    // vector<ll> dp(n+1,-1);
 	ll mx=0;
 	for(int i=1;i<=n;i++){
 		mx=max(mx,dfs(i));
 	}   	
 	cout<<mx-1<<nl;
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

struct SuffixArray {
    vector<int> sa;
    const vector<int> s;

    SuffixArray(const vector<int>& str) : s(str) {
        int n = s.size(), k;
        sa.resize(n);
        iota(sa.begin(), sa.end(), 0);
        vector<int> rank(s.begin(), s.end()), tmp(n);
        auto cmp = [&](int i, int j) {
            if (rank[i] != rank[j]) return rank[i] < rank[j];
            else return rank[(i+k) % n] < rank[(j+k) % n];
        };
        for (k = 1; k < n; k *= 2) {
            sort(sa.begin(), sa.end(), cmp);
            tmp[sa[0]] = 0;
            for (int i = 1; i < n; i++) {
                tmp[sa[i]] = tmp[sa[i-1]] + (cmp(sa[i-1], sa[i]) ? 1 : 0);
            }
            swap(rank, tmp);
        }
    }

    int operator[](int k) const {
        return sa[k];
    }

    bool lt_substr(const vector<int>& t, int si = 0, int ti = 0) {
        int n = s.size();
        for (int i = 0; i < min(s.size(), t.size()); i++) {
            if (s[(si + i) % n] < t[(ti + i) % n]) return true;
            if (s[(si + i) % n] > t[(ti + i) % n]) return false;
        }
        return false;
    }

    int lower_bound(const vector<int>& t) {
        int lb = -1, ub = sa.size();
        while (ub - lb > 1) {
            int m = (lb + ub) / 2;
            if (lt_substr(t, sa[m])) lb = m;
            else ub = m;
        }
        return ub;
    }

    int upper_bound(vector<int>& t) {
        t.back()++;
        int i = lower_bound(t);
        t.back()--;
        return i;
    }
};

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

    int N;
    cin >> N;
    vector<int> a(N), b(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i++) cin >> b[i];
    vector<int> c(N), d(N);
    for (int i = 0; i < N; i++) {
        c[i] = a[i] ^ a[(i+1) % N];
        d[i] = b[i] ^ b[(i+1) % N];
    }
    SuffixArray sa(d);
    int lb = sa.lower_bound(c);
    int ub = sa.upper_bound(c);
    vector<pair<int, int>> ans;
    for (int i = lb; i < ub; i++) {
        int k = (N - sa[i]) % N;
        int x = a[k] ^ b[0];
        ans.push_back({k, x});
    }
    sort(ans.begin(), ans.end());
    for (auto& p : ans) cout << p.first << " " << p.second << "\n";
}

Measured memory_bytes: 10960
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	int N;
	string s[100005];
	ll ans = 0;
	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}

	sort(s, s + N);
	ll c = 0;
	for (int i = 0; i < N - 1; i += c + 1) {
		c = 0;
		for (int j = i + 1; j < N; j++) {
			if (s[i] == s[j]) {
				c++;
			} else {
				break;
			}
		}
		ans += c * (c + 1) / 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7424
#include <iostream>
#include <cmath>

using namespace std;
using ll = long long int;

const ll MOD = pow(10, 9) + 7;

ll kai(int n)
{
    ll ans = 1;
    for (int i = 2; i <= n; ++i) {
        ans = (ans * i) % MOD;
    }
    return ans;
}

int main()
{
    ll n, m; cin >> n >> m;

    if (abs(n - m) > 1) cout << 0 << endl;
    else if (n == m) cout << (kai(n) * kai(m)) * 2 % MOD << endl;
    else cout << (kai(n) * kai(m)) % MOD << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main():

    N, X = map(int, input().split())
    L = list(map(int, input().split()))

    D = 0
    ans = 0

    if D <= X:
        ans += 1

    for i in L:
        D += i
        if D <= X:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

int main(){
    int n,ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        int l,r;
        cin>>l>>r;
        ans+=r-l+1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define np(str) next_permutation(str.begin(),str.end())
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for( i=n-1;i>=0;i--)
#define rep(i,n) for( i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int M = 1e9 + 7;
ll INF = 1e10;

ll n, m;


int main() {
	// your code goes here
	IOS;

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, t, k, x, y, z,  N;
	cin >> n;
	char c[n];
	rep(i, n)
	cin >> c[i];
	ll cnt = 0;
	ll suff[n + 1];
	suff[n] = 0;
	repr(i, n) {
		suff[i] = suff[i + 1];
		if (c[i] == 'R')
			suff[i]++;
	}
	ll ans = 0;
	rep(i, n) {
		if (c[i] == 'W') {
			if (suff[i + 1] - cnt > 0) {
				ans++;
				cnt++;
			}
		}
	}
	cout << ans;


	return 0;
}

Measured memory_bytes: 5384
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <list>
#define MAX_M 1000
#define MAX_N 10000

using namespace std;

int atoi(string s){
	int res = 0;
	for(int i = 0;i < s.size();i++){
		res *= 10;
		res += s[i] - '0';
	}
	return res;
}


int main(void){
	int n, m;
	list<int> sur; // 生き残りプレイヤー番号
	
	string s;
	while(1){
		cin >> m >> n;
		if(m == 0 && n == 0){
			break;
		}
		for(int i = 0;i < m;i++){
			sur.push_back(i + 1);
		}

		list<int>::iterator it = sur.begin(), next = sur.begin();
		next++;
		for(int i = 1;i <= n;i++){
			cin >> s;
			if(sur.size() == 1){
				continue;;
			}

			if(i % 15 == 0 && s == "FizzBuzz"){
				it++;
				next++;
			}else if(i % 15 != 0 && i % 5 == 0 && s == "Buzz"){
				it++;
				next++;
			}else if(i % 15 != 0 && i % 3 == 0 && s == "Fizz"){
				it++;
				next++;
			}else if(i % 3 != 0 && i % 5 != 0 && i % 15 != 0 && s != "FizzBuzz" && s != "Buzz" && s != "Fizz" && atoi(s) == i){
				it++;
				next++;
			}else{
				sur.erase(it);
				it = next;
				next++;
			}
			if(sur.end() == next){
				next = sur.begin();
			}
			if(sur.end() == it){
				it = sur.begin();
			}
		}
		it = sur.begin();
		for(int i = 0;i < sur.size();i++){
			if(i != 0){
				cout << " ";
			}
			cout << *it;
			it++;
		}
		cout << endl;
		sur.clear();

	}
	return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
#define MAX 51
#define INF 1234567890LL
 
inline bool range(ll l, ll r, ll x) { return l<=x && x<=r; }
 
int main() {
    int n, k;
    cin >> n >> k;
    ll xs[MAX], ys[MAX];
    ll xl[MAX], yl[MAX];
    for(int i=0; i<n; i++) {
        cin >> xs[i] >> ys[i];
        xl[i] = xs[i];
        yl[i] = ys[i];
    }
    sort(xl, xl+n);
    sort(yl, yl+n);
    
    ll res= INF * INF * 4;
    
    for(int a=0; a<n; a++) for(int b=a+1; b<n; b++)
    for(int c=0; c<n; c++) for(int d=c+1; d<n; d++){
        int ct = 0;
        ll s = (yl[b]-yl[a])*(xl[d]-xl[c]);
        if(s>=res) continue;
        for(int i=0; i<n; i++) {
            if(range(yl[a], yl[b], ys[i]) && range(xl[c], xl[d], xs[i])) ct++;
        }
        if(ct>=k) res = s;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
object Main {
  case class Line(string: String) {
    def strings: Seq[String] = string.split(' ')
    def ints: Seq[Int] = strings.map(_.toInt)
    def i(n: Int): Int = ints(n)
  }

  def readLine: Line = Line(io.StdIn.readLine())
  def readLines(n: Int): Seq[Line] = List.fill(n)(Line(io.StdIn.readLine()))

  def yesNo(b: Boolean): String = if (b) "Yes" else "No"

  def main(args: Array[String]) {
    val Seq(a, b) = readLine.ints
    val c: Int = a / b
    val d: Int = a % b
    val e: Double = a.toDouble / b.toDouble
    println(f"$c $d $e%.5f")
  }
}

Measured memory_bytes: 44124
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

const int MAX = 100010;

int64_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int64_t COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<int64_t> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    COMinit();
    int64_t ans = 0;
    for(int i=0; i<N; i++) {
        ans = (ans - COM(N-1-i, K-1) * A[i]) % MOD;
        ans = (ans + COM(i, K-1) * A[i]) % MOD;
    }

    if(ans < 0) {
        ans += MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328