akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    val m = (0..2018).map { i -> (0..2018).map { (i*it)%2019 } }
    val (l, r) = readLine()!!.split(" ").map { it.toInt() }

    if(r-l>=2018) {
        println(0)
        return
    }

    val f = BooleanArray(2019)
    (l..r).toList().combinationPairs().forEach {
        f[((it.first%2019)*(it.second%2019))%2019] = true
    }

    val ans = f.indexOf(true)
    println(ans)
}

fun <E> List<E>.combinationPairs(): List<Pair<E, E>>
        = this.indices.flatMap { i -> (i+1 until this.size).map { j -> Pair(this[i], this[j]) } }



Measured memory_bytes: 204688
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <vector>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i_, __start, __end) for(ll i_=(ll)__start; i_<(ll)__end; i_++)
#define print(_a) cout << _a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");


int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    print(a*b/2);
   
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-9


bool primes[1000000];

void make_prime(){
	for(int i=2; i<1000000; i++)primes[i]=true;
	for(int i=2; i*i<=1000000; i++)
		for(int j=i*2; j<1000000; j+=i)primes[j]=false;
}

int main(){
	int n,ret;
	make_prime();
	while(~scanf("%d",&n)){
		ret = 0;
		for(int i=2; i<=n; i++)if( primes[i] )ret++;
		printf("%d\n",ret);
	}
	return 0;
}

Measured memory_bytes: 1848
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define per(i,n) for ((i)=n;(i)>=(1);(i)--)
using namespace std;
int n,m,k,i,j,ans;
char mp[805][805];
int dis[805][805],sx,sy;
queue<int> qx,qy;
int main(){
	scanf("%d%d%d",&n,&m,&k);
	memset(dis,0x12,sizeof(dis));
	rep(i,n){
		scanf(" ");
		rep(j,m){
			scanf("%c",&mp[i][j]);
			if(mp[i][j]=='S'){
				sx=i;
				sy=j;
				if(i==1||i==n||j==1||j==m){
					puts("0");
					return 0;
				}
				dis[i][j]=0;
			}
		}
	}
	qx.push(sx);qy.push(sy);
	while(!qx.empty()){
		int x=qx.front(),y=qy.front();qx.pop();qy.pop();
		if(dis[x][y]>=k) continue;
		for(int nx=x-1;nx<=x+1;nx++)for(int ny=y-1;ny<=y+1;ny++){
			if(nx<1||nx>n||ny<1||ny>m) continue;
			if(abs(nx-x)+abs(ny-y)!=1) continue;
			if(mp[nx][ny]=='#') continue;
			if(dis[nx][ny]<=dis[x][y]+1) continue;
			dis[nx][ny]=dis[x][y]+1;
			qx.push(nx);qy.push(ny);
		}
	}
	ans=0x12121212;
	rep(i,n)rep(j,m) if(dis[i][j]<=k) ans=min(ans,1+(min(min(i-1,n-i),min(j-1,m-j))+k-1)/k);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3456
#include<stdio.h>

int main(void)
{
	int a[4];
	int b[4];
	int i, j, k;
	int hit;
	int blow;
	int f;
	
	while (1) {
		hit = 0;
		blow = 0;
		
		for (i = 0; i < 4; i++) {
			if (scanf("%d", &a[i]) == EOF) {
				return 0;
			}
		}
		for (i = 0; i < 4; i++) {
			scanf("%d", &b[i]);
		}
		
		for (i = 0; i < 4; i++) {
			f = 0;
			
			for (j = 0; j < 4; j++) {
				if (a[i] == b[i] && f == 0) {
					hit++;
					f++;
				}
				else if (a[i] == b[j] && f == 0) {
					blow++;
				}
			}
		}
		
		printf("%d %d\n", hit, blow);
	}
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int r,g;
    cin>>r>>g;
    //(r+x)/2==g  x=2g-r
    cout<<2*g-r<<endl;
    return 0;
}


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

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif


int main(int argc, char **argv){
	std::vector<int> l(10);
	char tmp;
	int v0, v1;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	
	while(ifs >> l[0] >> tmp >> l[1] >> tmp >> l[2] >> tmp >>  l[3] >> tmp
		>> l[4] >> tmp >> l[5] >> tmp >> l[6] >> tmp >> l[7] >> tmp >> l[8] >> tmp 
		>> l[9] >> tmp >> v0 >> tmp >> v1){
#else
	while(std::cin >> l[0] >> tmp >> l[1] >> tmp >> l[2] >> tmp >>  l[3] >> tmp
		>> l[4] >> tmp >> l[5] >> tmp >> l[6] >> tmp >> l[7] >> tmp >> l[8] >> tmp 
		>> l[9] >> tmp >> v0 >> tmp >> v1){
#endif

		int sum = 0;
		for(int i = 0; i < l.size(); i++){
			sum += l[i];
		}

		double t = double(sum) / (v0 + v1);
		double p = v0 * t;

		for(int i = 0; i < 10; i++){
			p -= l[i];
			if(p <= 0){
				std::cout << i + 1 << std::endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2984
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>

using namespace std;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    string s;
    cin >> s;
    cout << s << (s[s.length() - 1] != 's' ? "s" : "es") << endl;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

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

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

struct Edge {
	int to;
	ll cost;
};

vector<vector<Edge>> g;
vector<ll> dist;

void dfs(int x, int p) {
	for (int i = 0; i < g[x].size(); i++) {
		if (g[x][i].to == p) {
			continue;
		}
		dist[g[x][i].to] = dist[x] + g[x][i].cost;
		dfs(g[x][i].to, x);
	}
}

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N;
	cin >> N;
	g.resize(N);
	dist = vector<ll>(N, 0);

	for (int i = 0; i < N - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;

		g[u - 1].push_back({v - 1, w});
		g[v - 1].push_back({u - 1, w});
	}

	dfs(0, -1);

	for (int i = 0; i < N; i++) {
		if (dist[i] % 2 == 0) {
			cout << 0 << endl;
		} else {
			cout << 1 << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 9984
#include<iostream>
#include<vector>
#include<string>

using namespace std;
int N;
vector<int> V;
vector<int> C;
vector<int> D;
int main(){
  cin >> N;
  V.resize(N);
  C.resize(N);
  D.resize(N);
  for(int i = 0;i<N;i++){
    cin >> V[i];
  }
  for(int i = 0;i<N;i++){
    cin >> C[i];
  }
  
  for(int i = 0;i<N;i++){
    D[i] = V[i] - C[i];
  }

  int ret = 0;
  for(int i = 0; i < N; i++){
    if(D[i] > 0){
      ret = ret+D[i];
    }
  }

  cout << ret << endl;
  return 0;
}




Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    string s;
    cin >> s;
    int g = 0;
    int p = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'g')
            g++;
        else
            p++;
    }
    int maxp = s.size() / 2;
    cout << (maxp - p) << "\n";

    return 0;
}

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

int main() {
	int a, b, c, s;
	cin >> a >> b >> c;
	if (a > b) {
		s = a;
		a = b;
		b = s;
	}
	if (b > c) {
		s = b;
		b = c;
		c = s;
	}
	if (a > b) {
		s = a;
		a = b;
		b = s;
	}

	cout << a << " " << b << " " << c << endl;
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz() size()
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define mp make_pair
#define int long long
#define rc(s) return cout<<s,0
//#define cin fin
//#define cout fout
using namespace std;


const int nmax=1e3+5;
const int mod=1e9+7;
const int mod1=998244353;

int n,k;
string s;

bool check(int i1,int i2){
    if((s[i1]=='0' && s[i2]>='1') || (s[i1]=='1' && s[i2]>='0' && s[i2]<='2')) return true;
    return false;
}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie();cout.tie();
    cin >> s;
    if(check(0,1)==true && check(2,3)==true) rc("AMBIGUOUS");
    else if(check(0,1)==true && check(2,3)==false) rc("MMYY");
    else if(check(0,1)==false && check(2,3)==true) rc("YYMM");
    else rc("NA");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	int ans = INF;
	for(int i=-100;i<=100;i++){
		int sum=0;
		rep(j,n){
			sum+=pow(a[j]-i,2);
		}
		ans = min(ans,sum);
	}
	cout << ans << endl;
	return 0;
}


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

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn main() {
    let s: Vec<char> = read_line::<String>()[0].chars().collect();
    let mut a: Vec<i64> = vec![0; s.len() + 1];

    for i in 0..s.len() {
        if s[i] == '<' {
            a[i + 1] = a[i] + 1;
        }
    }

    for i in (0..s.len()).rev() {
        if s[i] == '>' && a[i] <= a[i + 1] {
            a[i] = a[i + 1] + 1;
        }
    }

    println!("{}", a.iter().fold(0, |a, x| a + x));
}


Measured memory_bytes: 10996
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#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;}
#define DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b; cin >> a >> b;
    ll g = gcd(a, b);
    ll i = 1;
    set<ll> s;
    while (i*i<=g) {
        if (g%i==0) {
            s.insert(i);
            if (g/i!=i) s.insert(g/i);
        }
        i++;
    }
    s.erase(s.begin());
    ll ans = 1;
    while (!s.empty()) {
        ans++;
        ll ms = *(s.begin()); s.erase(s.begin());
        auto it = s.begin();
        while (it!=s.end()) {
            if ((*(it))%ms == 0) it = s.erase(it);
            else it++;
            if (it == s.end()) break;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 640
//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int i, o, t, j, l, s, z;
    cin >> i >> o >> t >> j >> l >> s >> z;
    ll ans = 0;
    ans += i / 2 * 2;
    ans += j / 2 * 2;
    ans += l / 2 * 2;
    if (i > 0 and j > 0 and l > 0) {
        ll now = 3;
        now += (i - 1) / 2 * 2;
        now += (j - 1) / 2 * 2;
        now += (l - 1) / 2 * 2;
        chmax(ans, now);
    }
    ans += o;
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;
const int N = 100007;
ll n , x , y , X[N] , Y[N] ;
char D[N];


double calc(double t){

    double xmax = -1e15 , xmin = 1e15 , ymax = -1e15 , ymin = 1e15;
    for(int i = 1 ;i <= n ; i++){
        double cx = X[i] , cy = Y[i];
        if(D[i] == 'L')
            cx -= t;
        else if(D[i] == 'R')
            cx += t;
        else if(D[i] == 'U')
            cy += t;
        else
            cy -= t;
            
        xmax = max(xmax , cx);
        xmin = min(xmin , cx);
        ymax = max(ymax , cy);
        ymin = min(ymin , cy);
    }
    return (xmax-xmin)*(ymax-ymin);
}


double ternary_search(double lo , double hi){

    for(int i = 1 ;i <= 500 ; i++){
        double m1 = (2*lo + hi)/3;
        double m2 = (lo + 2*hi)/3;
        if(calc(m1) < calc(m2))
            hi = m2;
        else
            lo = m1;
    }
    return calc(lo);
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    cin >> n;
    for(int i = 1;i <= n; i++)
        cin >> X[i] >> Y[i] >> D[i];

    double ans = ternary_search(0 , 2e8) ;
    printf("%0.12lf\n" , ans);
    
    return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  // j - i = a[i] + a[j]
  // => i + a[i] = j - a[j]
  map<ll, ll> l, r;
  rep(i, n) {
    l[i + a[i]]++;
    r[i - a[i]]++;
  }
  ll res = 0;
  for (auto ll : l) {
    res += ll.second * r[ll.first];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 38180
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvcha;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
/*
  for A以上B未満でI探索 for (int I = A; i <= B; i++)

  string s = to_string(i);

  char　小文字のほうが32大　　  　大文字と小文字の境=93

  大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

  int i = sqrt ( n ) で、ｎの平方根(9に対する3)をiに入れる

  pow(a,b) → aのb乗を求める

  s1.erase(n) 文字列s1の、n文字目以降削除             */

int a = 0, b = 0, c = 0, d = 0, x = 0, y = 0
, z = 0, n = 0, sum = 0, i = 0, ans = 0, cnt = 0;
string s = "";

int main(void) {
	cin >> a >> b;
	if (b % a == 0)ans = a;
	sec(a + b, b - a, ans==a);
	please AC;
}

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

int main() {
  int N;
  string c;
  cin >> N;
  vector<string>s(N);
  vector<int>p(N);
  vector<int>r(N);
  for(int i=0;i<N;i++){
    cin >> s.at(i) >> p.at(i);
  }
  for(int i=0;i<N;i++){
    int t=0;
    for(int j=0;j<N;j++){
      if(j!=i){
        if(s.at(j)<s.at(i)){
          t++;
        }else if(s.at(j)==s.at(i)&&p.at(j)>p.at(i)){
          t++;
        }
      }
      
    }
    r.at(t)=i+1;
  }
  for(int i=0;i<N;i++){
    cout << r.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
char az(int n){
	if (n == 0)return 'A';
	if (n == 1)return 'B';
	if (n == 2)return 'C';
	if (n == 3)return 'D';
	if (n == 4)return 'E';
	if (n == 5)return 'F';
	if (n == 6)return 'G';
	if (n == 7)return 'H';
	if (n == 8)return 'I';
	if (n == 9)return 'J';
	if (n == 10)return 'K';
	if (n == 11)return 'L';
	if (n == 12)return 'M';
	if (n == 13)return 'N'; 
	if (n == 14)return 'O';
	if (n == 15)return 'P';
	if (n == 16)return 'Q';
	if (n == 17)return 'R';
	if (n == 18)return 'S';
	if (n == 19)return 'T';
	if (n == 20)return 'U';
	if (n == 21)return 'V';
	if (n == 22)return 'W';
	if (n == 23)return 'X';
	if (n == 24)return 'Y';
	if (n == 25)return 'Z';

}

int W, H;
char s;
int ans;
int main(){
	scanf("%d %d", &W, &H);
	for (int x = 0; x < W; x++){
		for (int y = 0; y < H; y++){
			string c;
			cin >> c;
			if (c == "snuke"){
				s = az(y);
				ans = x + 1;
				
			}
			
		}
	}
	printf("%c%d\n", s, ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = n;
    int s = 0;
    for(int i = 0; i < 10; i++) {
      int t = m % 10;
      s += t;
      m /= 10;
      if(m == 0) break;
    }
    String ans = "No";
    if((n % s) == 0)  ans = "Yes";
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
n = int(input())
a, b = [int(x) for x in input().split()]
for _ in range(n - 1):
	c, d = [int(x) for x in input().split()]
	k = max((a - 1) // c + 1, (b - 1) // d + 1)
	a, b = c * k, d * k
print(a + b)

Measured memory_bytes: 3060
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
u_light = [[0]*w for _ in range(h)] #上をてらせる数
d_light = [[0]*w for _ in range(h)] #下
l_light = [[0]*w for _ in range(h)] #左
r_light = [[0]*w for _ in range(h)] #右

def count_light(i, j):
    if s[i][j] == '.':
        return 1
    else:
        return -10000

for i in range(w):
    d_light[-1][i] = count_light(-1, i)
    u_light[0][i] = count_light(0, i)
for j in range(1, h):
    for i in range(w):
        d_light[-(j+1)][i] = max(d_light[-j][i], 0) + count_light(-(j+1), i)
        u_light[j][i] = max(u_light[j-1][i], 0) + count_light(j, i)

for i in range(h):
    l_light[i][0] = count_light(i, 0)
    r_light[i][-1] = count_light(i, -1)
for j in range(1, w):
    for i in range(h):
        l_light[i][j] = max(l_light[i][j-1], 0) + count_light(i, j)
        r_light[i][-(j+1)] = max(r_light[i][-j], 0) + count_light(i, -(j+1))

score = 0
tmp_score = 0
for i in range(h):
    for j in range(w):
        tmp_score = u_light[i][j] + d_light[i][j] + l_light[i][j] + r_light[i][j]
        if tmp_score > score:
            score = tmp_score
print(score-3) # 3回ダブっているので除去


Measured memory_bytes: 360308
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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












int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	cout << ((a + b + c >= 22) ? "bust" : "win") << endl;
}

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

using namespace std;

int main() {
    int N; cin>>N;
    vector<int> A(N);

    double ans=0.0;
    for (int i=0;i<N;i++) {
        cin >> A[i];
        ans += 1.0/A[i];
    }

    cout << std::setprecision(10) << 1.0 / ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, A, B;
    cin >> N >> A >> B;
    int ans = 0;
        for(int i = 1; i <= N; i++){
        int X = i;
        int Y = 0;
            while(X != 0){
            Y += X % 10;
            X  = X / 10; 
            }
            if(A <= Y && Y <= B){
            ans+=i;
            }
        }
    cout << ans << endl;
}

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

namespace ConsoleApp1
{
    static class BShiftonly
    {        
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ');
            var cnt = 0;

            while (true)
            {
                if (a.Any(x => int.Parse(x) % 2 != 0))
                {
                    break;
                }

                a = a.Select(x => (int.Parse(x) / 2).ToString()).ToArray();
                cnt++;
            }            

            Console.WriteLine(cnt);
            Console.ReadLine();
        }
  }
}

Measured memory_bytes: 13396
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out){
            int n = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i <n ; i++) {
                arr[i]=in.nextInt();
            }
            int[] srr = new int[n];
            for (int i = 0; i <n ; i++) {
                srr[i]=arr[i];
            }
            Arrays.sort(srr);
            HashMap<Integer , Integer> freq = new HashMap<>();
            HashMap<Integer,Integer> map = new HashMap<>();
            for (int i = 0; i <n; i++) {
                if (!freq.containsKey(srr[i]))freq.put(srr[i],1);
                else freq.put(srr[i],freq.get(srr[i])+1);
                map.put(srr[i],i);
            }
            int ans = (n/2)-1;
            for (int i = 0; i <n ; i++) {
               int index = map.get(arr[i])-(freq.get(arr[i])-1);
                if (index<=ans) System.out.println(srr[ans+1]);
                else System.out.println(srr[ans]);
                freq.put(arr[i],freq.get(arr[i])-1);
            }




        }




    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt(){return  Integer.parseInt(next());}
        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

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

int main() {

    int a;
    string s;

    cin >> a >> s;

    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using static System.Console;

namespace ABC117D
{
    class MainClass
    {

        static long[] s;
        static long[] n;

        public static void Main(string[] args)
        {
            int mxd = 50;
            s = Array.ConvertAll(ReadLine().Split().ToArray(), long.Parse);
            n = Array.ConvertAll(ReadLine().Split().ToArray(), long.Parse);
            long num = s[0];
            long k = s[1];

            long[][] dp = Enumerable.Repeat<long[]>((Enumerable.Repeat<long>(-1,2).ToArray()),mxd+1).ToArray();
            //WriteLine(dp.Count());
            dp[mxd][0]=0;

            for(int i=mxd;i>0;i--){
                
                long mask = 1L<<(i-1);

                int cnt = 0;
                for(int j=0;j<num;j++){
                    if((n[j]&mask)>0)cnt++;
                }

                long cost0 = mask*cnt;
                long cost1 = mask*(num-cnt);

                //WriteLine("i, mask,cost0,cost1 "+ i+" " + mask + " " + cost0 + " " + cost1);


                //smaller->smaller
                if(dp[i][1]!=-1){
                    dp[i-1][1]=dp[i][1]+Max(cost0,cost1);
                    //WriteLine("here dp[i-1][1] "+ dp[i-1][1] + " " + dp[i][1]+" " + cost0);
                }

                //exact->smaller
                if(dp[i][0]!=-1){
                    if((k&mask)>0) dp[i-1][1] = Max(dp[i][0]+cost0,dp[i-1][1]);
                }

                //exact->exact
                if(dp[i][0]!=-1){
                    if((k&mask)>0) dp[i-1][0] = dp[i][0]+cost1;
                    else dp[i-1][0]=dp[i][0] + cost0;
                }

                //WriteLine("dp[i-1][0],dp[i-1][1] " + dp[i-1][0] + " " +dp[i-1][1]);
            }

            WriteLine(Max(dp[0][0],dp[0][1]));


        }
    }
}


Measured memory_bytes: 31196
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

const int LIM=1<<16;
bool sosu[LIM];

int main() {
	int i,j;
	for(i=0;i<LIM;i++)sosu[i]=true;
	sosu[0]=sosu[1]=false;
	for(i=0;i<LIM;i++){
		if(sosu[i]){
			for(j=i*2;j<LIM;j+=i){
				sosu[j]=false;
			}
		}
	}
	int n;
	while(n=in()){
		int res=0;
		for(i=0;i<=n/2;i++){
			if(sosu[i]&&sosu[n-i])res++;
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool canGoal(vector<int> &v){
    int l = 0;
    for (int i = 0; i < v.size(); i++)
    {
        if(i>l){
            return false;
        }
        l = max(l,i+v[i]);
    }
    return true;
}
int main(){
    int a;
    cin >> a;
    vector<int> vec(a);
    for (size_t i = 0; i < a; i++)
    {
        cin >> vec[i];
        vec[i]/=10;
    }
    bool result = 1;
    if(!canGoal(vec))result = false;
    reverse(vec.begin(),vec.end());
    if(!canGoal(vec))result = false;
    
    cout << (result ? "yes":"no") << endl;
    return 0;
}


Measured memory_bytes: 3892
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int gcd(int a,int b){
	if(!b) return a;
	return gcd(b,a%b);
}

int a,b;

int main(){
	while(cin>>a>>b) cout<<gcd(a,b)<<endl;
}

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

#define repfrom(i, from, n) for (ll i = (from); i < (n); i++)
#define rep(i, n) repfrom(i, 0, n)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)

using namespace std;

using ll = long long;
using p  = pair<ll, ll>;
constexpr ll INF = 1LL << 62;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    for (auto&& a : A) {
        cin >> a;
    }
    for (auto&& b : B) {
        cin >> b;
    }
    
    ll ans = 0;
    for (ll k = 0; k < 29; k++) {
        ll mask = 1 << k;
        
        vector<ll> b;
        transform(B.begin(), B.end(), back_inserter(b), [mask](ll n) { return n % (mask << 1); });
        sort(b.begin(), b.end());
        
        ll ones = 0;
        for (auto a : A) {
            ll amod = a % (mask << 1);
            auto pt1 = lower_bound(b.begin(), b.end(), mask - amod);
            auto pt2 = lower_bound(b.begin(), b.end(), 2 * mask - amod);
            auto pt3 = lower_bound(b.begin(), b.end(), 3 * mask - amod);
            auto pt4 = lower_bound(b.begin(), b.end(), 4 * mask - amod);
            ones += ll(pt2 - pt1) + ll(pt4 - pt3);
        }
        
        if (ones % 2) {
            ans += mask;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 7060
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
 
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t ;
		Set<Integer> set = new HashSet<Integer>();
		while(n-- !=0) {
			t = sc.nextInt();
			if(set.contains(t))
				set.remove(t);
			else
				set.add(t);
		}
		System.out.println(set.size());
	}	
}

Measured memory_bytes: 62704
n=int(input())
l=[int(input()) for _ in range(n)]
l.sort()
m=sorted((-1)**(i+1) if i==0 or i==n-1 else 2*((-1)**(i+1)) for i in range(n))
f=lambda x,y:x*y
a=abs(sum(map(f,l,m)))
b=abs(sum(map(f,l[::-1],m)))
print(max(a,b))

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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int N, count, ans = 0;
	
	cin >> N;
	
	int A[N][2];
	
	for(int i=0; i<2; i++){
		for(int j=0; j<N; j++)
			cin >> A[j][i];
	}
	
	for(int i=0; i<N; i++){
		count = 0;
		for(int j=0; j<N; j++){
			if(j < i)
				count += A[j][0];
			else{
				if(j == i)
					count += A[j][0];
				count += A[j][1];
			}	
		}
		ans = max(ans, count);
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
            System.out.println("Possible");
        else
            System.out.println("Impossible");
    }
}

Measured memory_bytes: 21844
"use strict"
function Main(input) {
  input.trim();
  for(var i=input;true;i++){
  if(primeNumber(i)){
  console.log(i);
    break;
  }
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
function primeNumber(n) {
 if (n === 2) return true;
 for (let i = 2; i < n; i++) {
   if (n % i === 0) return false;
 }
 return true;
}

Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

int main(void) {
  int n;cin>>n;
  vector<l_l> A;
  ll tmp;
  rep(i,0,n-1) {
    cin>>tmp;
    A.push_back({tmp,i});
  }

  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());

  vector<vector<ll>> DP(2002,vector<ll>(2002,0));

  // rep(i,0,n-1) {
  for(int i = 0 ; i < n ; i++){
    ll act=A[i].first;
    ll no=A[i].second;
    // rep(x,0,i) {
    for(int x = 0 ; x <= i ; x++){
      int y = i - x;
      // DP[x+1][y] = max(DP[x+1][y],DP[x][y]+act*(no-x));
      // DP[x][y+1] = max(DP[x][y+1],DP[x][y]+act*(no-(n-1-y)));
      if(DP[x+1][y] < DP[x][y] + abs(no-x) *act){
          DP[x+1][y] = DP[x][y] + abs(no-x) *act;
      }
      if(DP[x][y+1] < DP[x][y] + abs(no-(n-1-y)) *act){
          DP[x][y+1] = DP[x][y] + abs(no-(n-1-y)) *act;
      }
    }
  }

  // pr("===");

  // for(int i = 0 ; i < n+1; i++){
  //     for(int j = 0 ; j < n+1; j++){
  //         cout << DP[i][j] << " ";
  //     }
  //     cout << endl;
  // }

  // pr("===");

  ll ans = 0 ;

  for(ll i = 0 ; i <= n ; i++){
      if(ans < DP[i][n-i]){
          ans = DP[i][n-i];
      }
  }

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


Measured memory_bytes: 34676
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,c,d;cin>>a>>b>>c>>d;
    ll arr[4];
    arr[0]=a*c;
    arr[1]=a*d;
    arr[2]=b*c;
    arr[3]=b*d;
    cout<<max(arr[0],max(arr[1],max(arr[2],arr[3])))<<endl;
    return 0;
}


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

ll n,q,pt[200001] = {};
bool visited[200001] = {};
vector<int> G[200001];

void dfs(int r,ll p){
    visited[r] = true;
    pt[r] = p;
    for(int i = 0;i < G[r].size();i ++){
        int to = G[r][i];
        if(!visited[to]) dfs(to,pt[r]+pt[to]);
    }
}

int main(){
    cin >> n >> q;
    for(int i = 0;i < n-1;i ++){
        int a,b;
        cin >> a >> b;
        a --;b --;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(int i = 0;i < q;i ++){
        ll p,x;
        cin >> p >> x;
        p --;
        pt[p] += x;
    }
    dfs(0,pt[0]);
    for(int i = 0;i < n;i ++){
        cout << pt[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 24448
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	int n;
	char s[100];
	scanf("%s", s);
	getchar();
	s[5] = ' ';
	s[13] = ' ';
	printf("%s\n", s);
#ifdef _DEBUG
	printf("Press enter to exit\n");
	getchar();
#endif
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
#define ll long long

int main() {
	ll n, m, num = 0, ans = 0, hoge;
	pair<ll, ll> p[100010];
	cin >> n >> m;
	for (ll i = 0; i < n; i++) {
		cin >> p[i].first >> p[i].second;
	}
	sort(p, p + n);
	for (ll i = 0; num < m; i++) {
		hoge = min(p[i].second, (m - num));
		ans += hoge * p[i].first;
		num += hoge;
	}
	cout << ans << endl;
	return 0;
}

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

count = 0
for n in range(105, N+1, 2):
    divi_count = 0
    for divi in range(1, n+1, 2):
        if n%divi == 0:
            divi_count += 1
    if divi_count == 8:
        count += 1
print(count)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
// #define DEBUG 10

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7, maxn = 500050;
const double PI = acos(-1);

vector<int> p(maxn, 0);
void init(int n){
    for (int i=0; i<=n; i++){
        p[i] = i;
    }
}
int main (){
    ios_base::sync_with_stdio(false);
    ll n, p, ans = 0, atual = 0, pot = 1;
    string s;
    cin >> n >> p;
    cin >> s;
    // n = s.size();

    vector<ll> rest(p + 1, 0);
    rest[0] = 1;

    if (__gcd(10LL, p) == 1){
        for (ll i=n-1; i>=0; i--){
            ll dig = (s[i] - '0');
            atual = (dig*pot + atual)%p;
            ans += rest[atual];
            rest[atual]++;
            pot = (pot*10)%p;
        }

        cout << ans << endl;
    }
    else {
        for (int i=n-1; i>=0; i--){
            ll dig = s[i] - '0';
            if (dig%p == 0) ans+=i+1;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 5620
#include <bits/stdc++.h>
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)

#define FOREACH(x,a) for(auto&& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_ll.hpp>
// using namespace boost::multiprecision; // cpp_ll

#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>

#define pb(a) push_back(a)
#define mp make_pair


signed main(){
    SCIN(s,t);
    int n = s.size();
    bool flag = false;
    REP(i,n){
        string s2 = s.substr(i);
        s2 += s.substr(0, i);
        if(s2 == t){
            flag = true;
        }
    }
    Yes(flag);

}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

num = int(1e5)

dp = [0]*(num+1)

for e in A:
  dp[e] += 1

cnt = 0
for i in range(1, num+1):
  if dp[i] > 1:
    cnt += dp[i] - 1

ans = N - (cnt + (cnt%2))
print(ans)


Measured memory_bytes: 52908
def main(str)
  lines = str.split("\n")
  x, _ = lines[0].split(" ").map(&:to_i)
  ps = (lines[1] || '').split(" ").map(&:to_i).sort
  (0..10000).each do |i|
    return x - i unless ps.include?(x - i)
    return x + i unless ps.include?(x + i)
  end
end

unless ENV["TEST"]
  puts(main($stdin.read.chomp))
  exit(0)
end

require 'minitest/autorun'

class TestA < Minitest::Test
  def test_main
    assert_equal(8, main("6 5
4 7 10 6 5"))         
    assert_equal(9, main("10 5
4 7 10 6 5"))
    assert_equal(100, main("100 0
"))
  end
end




Measured memory_bytes: 14336
#include <cstdio>
#include <algorithm>
using namespace std;

#define File(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

int gcd(int x, int y){
	int t;
	while(y) t = x, x = y, y = t % y;
	return x;
}

const int N = 20005, PR = 32000;
int res[N], rc = 0;

int a[N], b[N], p[PR], pc = 0;
bool np[PR];

void primeList(int n){
	for(int i=2; i<=n; i++){
		if(!np[i]) p[++pc] = i;
		for(int j=1; j<=pc && i * p[j] <= n; j++){
			np[i * p[j]] = true;
			if(i % p[j] == 0) break;
		}
	}
}

int main(){
	// File("4125");
	primeList(31622);
	int n, d = 0;
	scanf("%d", &n);
	for(int i=n; i>=0; i--){
		scanf("%d", a + i);
		d = gcd(abs(a[i]), d);
	}
	for(int i=1; i<=pc; i++){
		if(d % p[i] == 0) res[++rc] = p[i];
		while(d % p[i] == 0) d /= p[i];
		if(a[0] % p[i] == 0 && p[i] <= n){
			for(int j=1; j<=n; j++) b[j] = (a[j] % p[i] + p[i]) % p[i];
			for(int j=n; j>=p[i]; j--)
				b[j - p[i] + 1] = (b[j - p[i] + 1] + b[j]) % p[i];
			bool flag = true;
			for(int j=1; j<p[i]; j++)
				if(b[j] != 0){
					flag = false;
					break;
				}
			if(flag) res[++rc] = p[i];
		}
	}
	if(d != 1) res[++rc] = d;
	sort(res + 1, res + 1 + rc);
	res[0] = 0;
	for(int i=1; i<=rc; i++)
		if(res[i] != res[i - 1]) printf("%d\n", res[i]);
	return 0;
}

Measured memory_bytes: 256
n=int(input())
v = [int(i) for i in input().split()]
v.sort()
ans = 0
for j in range(0,n-1):
    if(j==0):
        ans = (v[j]+v[j+1])/2
    else:
        ans = (ans + v[j+1])/2
print(ans)

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

const int MOD = 998244353;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> l(k), r(k);
    for(int i = 0; i < k; i++) cin >> l[i] >> r[i];
    vector<int> dp(n + 1);
    dp[1] = 1;
    dp[2] = -1;
    for(int i = 1; i <= n; i++) {
        dp[i] += dp[i - 1];
        dp[i] %= MOD;
        for(int j = 0; j < k; j++) {
            if(i + l[j] <= n) {
                dp[i + l[j]] += dp[i];
                dp[i + l[j]] %= MOD;
            }
            if(i + r[j] <= n) {
                dp[i + r[j] + 1] -= dp[i];
                dp[i + r[j] + 1] = (dp[i + r[j] + 1] % MOD + MOD) % MOD;
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
}


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

int main(){
  int x1,x2,x3,x4,x5;
  cin>>x1>>x2>>x3>>x4>>x5;
  if(x1==0){
    cout<<1<<"\n";
  }
  else if(x2==0){
    cout<<2<<"\n";
  }
  else if(x3==0){
    cout<<3<<"\n";
  }
  else if(x4==0){
    cout<<4<<"\n";
  }
  else if(x5==0){
    cout<<5<<"\n";
  }
}

Measured memory_bytes: 3624
#include<stdio.h>

int F(int n){
   if(n%2==0){
      return n/2;
   }else{
      return 3*n+1;
   }
}

int main(){
   int s,i,m,flag=0;
   int a[1000001];
   scanf("%d",&s);
   a[0] = 0;
   a[1] = s;
   for(int i=2;i<=1000001;i++){
      a[i] = F(a[i-1]);
   }

   for( i=1;i<=1000001;i++){
      for(m=i+1;m<=1000001;m++){
         if(a[i]-a[m]==0){
            flag = 1;
            break;
         }
      }
      if(flag == 1){
         printf("%d\n",m);
         break;
      }
   }
   return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  int a,b,c=0,d=1e3,e,n,m,x,y;
  string s;
  c(s);
  rep(i,0,s.size()-2){
    a=s[i]; a-=48;
    b=s[i+1]; b-=48;
    c=s[i+2]; c-=48;
    x=100*a+10*b+c;
    x=abs(753-x);
    if(d>x) d=x;
  }
  co(d);
      
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  static int a, b, c;

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

    a = sc.nextInt(); b = sc.nextInt(); c = sc.nextInt();

    if(a == 7 && b == 5 && c == 5 ||
      a == 5 && b == 7 && c == 5 ||
      a == 5 && b == 5 && c == 7){
      System.out.println("YES");
    }
    else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 9428