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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y,z; cin>>x>>y>>z;
    x-=z;
    cout<<x/(y+z)<<endl;
    return 0;
}


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

int main(){
   int a,b; cin>>a>>b;
   cout<<a*b<<endl;
   return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    string s;
    cin>>s;
    sort(s.begin(),s.end(),greater<int>());
    if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]) cout<<"Yes"<<'\n';
    else cout<<"No"<<'\n';
    }

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
	long long ta,ao,k,cnt=1;
	cin>>ta>>ao>>k;
	while( k-- ){
		if( cnt&1 )  //ta开始 
		{
			if( ta&1 )
				ta--;
			ao+=ta>>1;
			ta>>=1;
		}
		else{
			if( ao&1 )
				ao--;
			ta+=ao>>1;
			ao>>=1;
		}
		cnt++;
	//	cout<<ta<<' '<<ao<<endl;
	}
	cout<<ta<<' '<<ao<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
// clang-format on

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

  if (L % 3 == 0) {
    double a = L / 3.0;
    double ans = a * a * a;
    printf("%.12f\n", ans);
    return 0;
  } else if (L % 3 == 1) {
    double a = (L) / 3.0;
    double ans = a * a * a;
    printf("%.12f\n", ans);
    return 0;
  } else if (L % 3 == 2) {
    double a = (L) / 3.0;
    double ans = a * a * a;
    printf("%.12f\n", ans);
    return 0;
  }

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val a = sc.nextInt()
    val b = sc.nextInt()
    println(a*b)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34220
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll A;
    ll i;
    ll dp[N+1][3][2];
    dp[0][0][0]=0;
    dp[0][0][1]=0;
    dp[0][1][0]=0;
    dp[0][1][1]=0;
    dp[0][2][0]=0;
    dp[0][2][1]=0;
    for(i=1;i<=N;i++){
        cin >> A;
        dp[i][0][0]=dp[i-1][0][1];
        dp[i][0][1]=dp[i-1][0][0]+A;
        dp[i][1][0]=max(dp[i-1][1][1],dp[i-1][0][0]);
        if(i>1)dp[i][1][1]=dp[i-1][1][0]+A;else dp[i][1][1]=0;
        dp[i][2][0]=max(dp[i-1][2][1],dp[i-1][1][0]);
        if(i>2)dp[i][2][1]=dp[i-1][2][0]+A;else dp[i][2][1]=0;
    }
    if(N%2==0){
        cout << max(dp[N-1][0][1],dp[N][1][1])<<endl;
    }else{
        cout << max(dp[N-2][0][1],max(dp[N-1][1][1],dp[N][2][1]))<<endl;
    }
    return 0;
}


Measured memory_bytes: 12568
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
const int INF = 1e9;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */


/** 幾何ライブラリ **/
// to do : 1183

#include <complex>

#define X real()
#define Y imag()

const double EPS = 1e-11;

typedef double D;
typedef complex<D> P; // Point

struct L { // Line
	P a, b;
	L(){}
	L(P aa, P bb) : a(aa), b(bb){}
};

// 共役複素数 conj(a);

// 符号
int sig(D a, D b=0) { return a < b - EPS ? -1 : (a > b + EPS ? 1 : 0); }

// 内積
D dot(P a, P b) { return (conj(a)*b).real(); }

// 外積
D cross(P a, P b) { return (conj(a)*b).imag(); }

// 線分abに対する点cの位置
enum CCW{LEFT=1, RIGHT=-1, BACK=2, FRONT=-2, ON=0};
int ccw(P a, P b, P c)
{
	b -= a, c -= a;
	D s = sig(cross(b, c));
	if (s) return s>0 ? LEFT : RIGHT;
	if (sig(dot(b, c))<0) return BACK;
	if (sig(abs(c), abs(b))>0) return FRONT;
	return ON;
}

// 直線abと点cの距離
D distLP(L l, P c)
{
	return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
}

// 線分abと点cの距離
D distSP(L l, P c)
{
	if (sig(dot(l.b-l.a, c-l.a))<0) return abs(c-l.a);
	if (sig(dot(l.a-l.b, c-l.b))<0) return abs(c-l.b);
	return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
}

// 線分と線分の交差判定
bool iSS(L s, L t)
{
	return (ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0)
			&& (ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0);
}

/** Problem CGL_2-B : Intersection **/
int main()
{
	L s, t;
	int q; cin>>q;
	rep(i, q) {
		cin>>s.a.X>>s.a.Y>>s.b.X>>s.b.Y;
		cin>>t.a.X>>t.a.Y>>t.b.X>>t.b.Y;
		cout << iSS(s, t) << endl;
	}
}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

int N,M,H,W,K,A,B;
string S;
//ここから書き始める


int main()
{
	cout << setprecision(10);
	int L ;
	cin >> N >> L;
	vector<string> S(N);
	rep(i,N){
		string s;
		cin >> s;
		S[i] = s;
	}
	sort(S.begin(),S.end());
	rep(i,N){
		cout << S[i] ;
	}
	cout << endl;
		
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int keta(int y){
    
    double c= y/100;
    int a=c;
    return a;
}
int main(){
    int x, ps;
    
    cin>>x;
    ps=keta(x);
    if(105*ps>=x) cout<<1;
    else cout<<0;
    
}

Measured memory_bytes: 256
use std::collections::BTreeMap;
use superslice::Ext;
fn main() {
    proconio::input! {
        n: usize,
        a: [i64;n],
    }
    let mut m: BTreeMap<i64,Vec<usize>> = BTreeMap::new();
    for i in 0..n {
        let v=i as i64-a[i];
        m.entry(v).or_insert(Vec::new()).push(i);
    }
    let mut c=0;
    for i in 0..n {
        let v=i as i64+a[i];
        if let Some(w)=m.get(&v) {
            c+=w.len()-w.lower_bound(&(i+1));
        }
    }
    println!("{}",c);
}

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

#define MOD 2019

main () {
  int l, r;
  scanf("%d %d", &l, &r);

  if (r-l >= MOD - l%MOD) {
    printf("0\n");
  }
  else {
    l %= MOD;
    r %= MOD;
    int min = MOD - 1;
    for (int i=l; i<r; i++) {
      for (int j=i+1; j<=r; j++) {
        int k = (i*j)%MOD;
        if (k < min) {
          min = k;
        }
      }
    }
    printf("%d\n", min);
  }

  return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	ll n;
	cin >> n;

	ll ans = n + 1;
	for(ll i = (int)sqrt(n); i >= 1; --i)
	{
		if (n % i == 0)
		{
			ans = i + n / i;
			break;
		}
	}
	cout << ans - 2;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <ctype.h>
#include <iostream>
using namespace std;

char check(char s3){
	if(isupper(s3)!=0)
		return tolower(s3);
	if(islower(s3)!=0)
		return toupper(s3);
	return s3;
}

int main(){
	string s1;
	string s2;
	getline(cin, s1);
	s2 = s1;

	for(int i=0; i<s1.length(); i++){
		s2[i] = check(s1[i]);
	}
	cout << s2 << endl;

	return 0;
}

Measured memory_bytes: 3096
import std.stdio;
import std.conv;
import std.array;

void main()
{
    int N = readln.split[0].to!int;
    int[] V = readln.split.to!(int[]);
    int[] C = readln.split.to!(int[]);

    int ans = 0;
    foreach (i; 0..N){
        if (V[i] > C[i]) ans += V[i] - C[i];
    }

    writeln(ans);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define W(x) cout << #x << " = " << x << endl;
#define pii pair<int, int>
#define ff first
#define ss second
#define ll long long
#define sort(x) sort(x.begin(), x.end())
using namespace std;



int main(){
	int n;
	cin >> n;
	vector<int> vet(n);
	int soma = 0;
	int maior = -1;
	for(auto&p:vet){
		cin >> p;
		soma += p;
		maior = max(maior, p);
	}
	cout << (soma - maior > maior ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 998244353;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main() {
	int n, m;
	int s = 0;
	cin >> n >> m;
	vector<int> x(m), d(m - 1);
	rep(i, 0, m)cin >> x[i];
	sort(all(x));
	s = x.back() - x.front();
	rep(i, 0, m - 1)d[i] = x[i + 1] - x[i];
	r_sort(d);
	n = min(n, m);
	rep(i, 0, n - 1)s -= d[i];
	printf("%d\n", s);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

class DisjointSet{
public:
  vector<int> rank,p;
  vector<int> sz;
 
  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size,0);
    p.resize(size,0);
    sz.resize(size,0);
    for(int i=0;i<size;i++) makeSet(i);
  }
 
  void makeSet(int x){
    p[x]=x;
    rank[x]=0;
    sz[x]=1;
  }
 
  bool same(int x,int y){
    return findSet(x)==findSet(y);
  }
 
  void unite(int x,int y){
    if(same(x,y)) return;
    link(findSet(x),findSet(y));
  }
 
  void link(int x,int y){
    if(rank[x]>rank[y]){
      p[y]=x;
      sz[x]+=sz[y];
    }else{
      p[x]=y;
      sz[y]+=sz[x];
      if(rank[x]==rank[y]){
        rank[y]++;
      }
    }
  }
 
  int findSet(int x){
    if(x!=p[x]){
      p[x]=findSet(p[x]);
    }
    return p[x];
  }
 
  int findSize(int x){
    return sz[findSet(x)];
  }
};


struct BipartiteMatching {
  vector<vector<int>> graph;
  vector<int> match,used;
 
  BipartiteMatching(int n):graph(n),used(n, 0),match(n, -1){}
 
  void add_edge(int u,int v){
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
 
  bool dfs(int now){
    used[now]=1;
    for(auto to:graph[now]){
      int to_match=match[to];
      if(to_match==-1||(!used[to_match]&&dfs(to_match))){
        match[now]=to;
        match[to]=now;
        return true;
      }
    }
    return false;
  }
 
  int bipartite_matching(){
    int res=0;
    for(int i=0;i<graph.size();i++){
      if(match[i]==-1){
        for(int j=0;j<graph.size();j++) used[j]=0;
        if(dfs(i)) res++;
      }
    }
    return res;
  }
};

int N,M;
vector<int> X,Y;

int main(){
  cin>>N>>M;
  X.resize(M);
  Y.resize(M);
  rep(i,M) cin>>X[i]>>Y[i];

  for(int i=0;i<M;i++){
      X[i]--;
      Y[i]--;
  }

  int ans1=0,ans2=0;
  DisjointSet us(M);
  for(int i=0;i<M;i++){
      for(int j=i+1;j<M;j++){
          if((X[i]==X[j]||Y[i]==Y[j])&&(!us.same(i,j))) us.unite(i,j);
      }
  }

  for(int i=0;i<M;i++){
      if(us.findSet(i)==i) ans2+=us.findSize(i)-1;
  }

  BipartiteMatching graph(2*N);

  for(int i=0;i<M;i++) graph.add_edge(X[i],N+Y[i]);
  ans1=graph.bipartite_matching();

  cout<<M-ans1<<" "<<ans2<<endl;

  return 0;
}



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


int main (void)
{
    int n;
    string s;
    cin >>n >>  s;
    int B = 0;
    int R = 0;
    int L = s.length();
    for(int i = 0; i < L; ++i) {
        if (s[i]=='B') ++B;
        else ++R;
    }
    if (B < R) {
        cout << "Yes";
    }
    else cout << "No";
}

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

room = [[[0]*10 for i in range(3)] for k in range(4)]
n =  int(input().strip())

for m in range(n):
    raw_data = input()
    data = list(map(int,raw_data.split()))
    room[data[0]-1][data[1]-1][data[2]-1]+=data[3]

for build in range(3):
    for floor in range(3):
        data = " "+str(room[build][floor][0])
        for No in range(1,10):
            data = data+" "+str(room[build][floor][No])
        print(data)
    print('#'*20)
for floor in range(3):
    data = " "+str(room[3][floor][0])
    for No in range(1,10):
        data = data+" "+str(room[3][floor][No])
    print(data)


Measured memory_bytes: 5620
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF =1e9+7;
ll a[200000],b[2000][2000];
int main()
{
    ll i,n,m,j,k,l;
    queue<int>q;
    scanf("%lld",&n);
    a[1]=1;
    q.push(1);
    for(i=1;i<=n;i++)
    {
        a[i]=INF;
    }
    a[1]=1;
    a[0]=INF;
    while(!q.empty())
    {
        ll nn=q.front();
        q.pop();
        ll ne=nn*10%n;
        for(i=0;i<10;i++)
        {
            if(a[ne]>a[nn]+i)
            {
                a[ne]=a[nn]+i;
                q.push(ne);
            }
            ne=(ne+1)%n;
        }
    }
    printf("%lld",a[0]);
    return 0;
}
 

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


int main()
{
	string s,c,s1="",s2="";
	cin>>s;
	int q,cho,f,cnt=0;
	cin>>q;
	for(int i=0;i<q;i++)
	{
		cin>>cho;
		if(cho==1)cnt++;
		else
		{
			cin>>f>>c;
			if(cnt%2==0)
			{
				if(f==1)s1=c+s1;
				else s2=s2+c;
			}
			else
			{
				if(f==1)s2=s2+c;
				else s1=c+s1;
			}
		}
	}
	if(cnt%2==0)cout<<s1<<s<<s2;
	else
	{
		reverse(s.begin(),s.end());
		reverse(s1.begin(),s1.end());
		reverse(s2.begin(),s2.end());
		cout<<s2<<s<<s1;
	}
}

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

int main()
{
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i, N) {
    cin >> d.at(i);
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      sum += d.at(i) * d.at(j);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

//G : vector<vector<int>> ...
template<typename G>
struct DoublingLowestCommonAncestor{
    const int LOG;
    vector<int> dep;
    const G &g;
    vector<vector<int>> table;

    //__builtin_clz:2進表記の際左側にいくつ0を埋めるか
    //32bit intで111(2)なら返す値は29
    DoublingLowestCommonAncestor(const G &g):g(g),dep(g.size()),LOG(32-__builtin_clz(g.size())){
        table.assign(LOG,vector<int>(g.size(),-1));
    }

    void dfs(int idx,int par,int d){
        table[0][idx]=par;
        dep[idx]=d;
        for(auto &to:g[idx]){
            if(to!=par) dfs(to,idx,d+1);
        }
    }

    void build(){
        dfs(0,-1,0);
        for(int k=0;k+1<LOG;k++){
            for(int i=0;i<table[k].size();i++){
                if(table[k][i]==-1) table[k+1][i]=-1;
                else table[k+1][i]=table[k][table[k][i]];
            }
        }
    }
    int query(int u,int v){
        //dep[u]>dep[v]として進める
        if(dep[u]>dep[v]) swap(u,v);
        //深さをそろえる
        for(int i=LOG-1;i>=0;i--){
            if(((dep[v]-dep[u])>>i)&1) v=table[i][v];
        }
        if(u==v) return u;
        for(int i=LOG-1;i>=0;i--){
            if(table[i][u]!=table[i][v]){
                u=table[i][u];
                v=table[i][v];
            }
        }
        return table[0][u];
    }
};

int main(){
    int n;cin>>n;
    vector<vector<int>> g(n);
    rep(i,n){
        int k;cin>>k;
        rep(j,k){
            int tmp;cin>>tmp;
            g[i].push_back(tmp);
            g[tmp].push_back(i);
        }
    }
    DoublingLowestCommonAncestor< vector<vector<int>> > lca(g);
    lca.build();
    int q;cin>>q;vector<int> ans;
    while(q--){
        int u,v;cin>>u>>v;
        ans.push_back(lca.query(u,v));
    }
    rep(i,ans.size()){cout<<ans[i]<<endl;}

    // //debug
    // cout<<endl;
    // rep(i,lca.table.size()){
    //     rep(j,lca.table[i].size()){
    //         cout<<lca.table[i][j]<<"  ";
    //     }cout<<endl;
    // }
    return 0;
}


Measured memory_bytes: 19120
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    string S; cin >> S;
    int N = S.size();

    vector<long long> val(2019, 0);
    long long fac = 1;
    long long cur = 0;
    
    val[cur]++;
    for (int i = 0; i < N; i++) {
        long long add = S[N-1-i] - '0';
        cur = (cur + fac * add) % 2019;
        fac = (fac * 10) % 2019;
        val[cur]++;
    }

    long long res = 0;
    for (int i = 0; i < val.size(); i++) {
        res += val[i] * (val[i] - 1) / 2;
    }
    
    cout << res << endl;
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3708
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int R = sc.nextInt();

		sc.close();

		if (N >= 10) {
			out.println(R);
		} else {
			out.println(R + (100 * (10 - N)));
		}

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

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

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll x,y,ans=0;
	cin >> x >> y;
	if(y<x){
		y*=-1;
		ans++;
	}
	cout << ans+min(abs(y-x),abs(x+y)+1) << endl;;
	return 0;
}

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

ans=[0]*(n+1)
for x in range(1,int(n**0.5)+2):
    for y in range(1,int(n**0.5)+2):
        for z in range(1,int(n**0.5)+2):
            if x**2+y**2+z**2+x*y+y*z+z*x<=n:
                ans[x**2+y**2+z**2+x*y+y*z+z*x]+=1

for item in ans[1:]:
    print(item)


Measured memory_bytes: 69628
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int s;
    cin >> s;
    int a,b;
    a = s/100;
    b = s - a*100;
    bool q,w;
    q = false;
    w = false;
    if(0<a&&a<=12) q = true;
    if(0<b&&b<=12) w = true;
    if(q&&w) cout << "AMBIGUOUS";
    else if(!q&&w) cout << "YYMM";
    else if(q&&!w) cout << "MMYY";
    else cout << "NA";
    return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int k, n;
int a[200100];

int solve() {
    int d = 0;
    for (int i = 0; i < n-1; i++) {
        d = max(d, a[i+1] - a[i]);
    }
    d = max(d, a[0]+k-a[n-1]);
    return k - d;
}

void input() {
    cin >> k >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int main()
{
    fastRead;
    int x, y;
    cin>>x>>y;
    if(y%2) {
        cout<<"No\n";
        return 0;
    }
    y/=2;
    int b = y - x;
    int a = x - b;
    if(a>=0 && b>=0) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
    
}

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

const int MAX_N = 300000;
int N;
ll A[MAX_N];
const ll MOD = 1e9 + 7;

void Main() {
  cin >> N;
  rep(i, N) cin >> A[i];

  ll ans = 0;
  ll bit = 1;
  rep(i, 60) {
    ll c0 = 0, c1 = 0;
    rep(j, N) if (A[j] & (1LL << i)) c1++; else c0++;
    (ans += (c0 * c1) % MOD * bit % MOD) %= MOD;
    (bit *= 2) %= MOD;
  }

  cout << ans << endl;
}

int main() {
  Main();
  return 0;
}

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

int main() {
	string s; cin >>s;
	int cnt =0;
	for(int i=0;i<6;++i){
		auto sub = s.substr(i,1);
		if(sub =="1") ++cnt;
	}
	cout << cnt ;
	return 0;
}

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

using namespace std;

int main()
{
    long long n, a, b;
    cin >> n >> a >> b;
    long long ab = a + b;
    long long ans = 0;
    ans += a * (n / ab);
    if(n == ab){
        n = 0;
    }else{
        n %= ab;
    }
    if(n >= a){
        ans += a;
    }else{
        ans += n;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
s = sum(a[1:])
ans = 0
mod = 10**9+7
for i in range(n):
  if i != 0:
    s -= a[i]
  ans += (a[i]*s)%mod
  ans %= mod
print(ans)

Measured memory_bytes: 31440
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

vector<pair<int,int>> to;
vector<bool> seen(50,false);
vector<vector<int>> go(50);
int cnt = 0;

void dfs(int a,int p = -1){
    if(seen[a]) return;
    seen[a] = true;
    for(auto r:go[a]){
        if(r == p) continue;
        if(to[cnt] == make_pair(min(a,r),max(a,r))) continue;
        dfs(r,a);
    }
}

int main(){
    int n,m;
    cin >> n >> m;
    int ans = 0;
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        to.push_back(make_pair(a,b));
        go[a].push_back(b);
        go[b].push_back(a);
    } 
    for(int i = 0; i < m; i++){
        bool flag = false;
        cnt = i;
        dfs(0);
        for(int j = 0; j < n; j++){
            if(!seen[j]) flag = true;
            else seen[j] = false;
        }
        if(flag) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int x = 800 * n;
  int y = 200 * (n / 15);
  cout << x - y << endl;
  return 0;
}
//templete by private_yusuke

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

int main(){
    char a;
    cin >> a;
    if(a>='a' && a<= 'z') cout << "a" << endl;
    else cout << "A" << endl;
    return 0;
}

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

int main(){
  long long int N, K, diffBefore, diffBefore2;
  cin >> N >> K;
  
  /*
  diffBefore = 0;
  diffBefore2 = 0;
  while(N != diffBefore2){
    diffBefore2 = diffBefore;
    diffBefore = N;
    N = abs( N - K );
  }
  */
  long long int rest = N % K;
    
  cout << (rest < abs(K - rest)?rest:abs(K - rest)) << endl;

}

Measured memory_bytes: 256
import sys,math,copy,queue,itertools,bisect,collections
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
n = NI()
s = [sys.stdin.readline().rstrip() for _ in range(n)]
s = set(s)
print (len(s))

Measured memory_bytes: 100848
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
using P=pair<int,int>;

#define _ cin.tie(0);ios::sync_with_stdio(false);
int MAXN=100111;

int main(){_
  ll n,h;
  ll a,b[MAXN],tmpa;
  cin>>n>>h;
  a=0;
  for(int i=0;i<n;i++){
    cin>>tmpa>>b[i];
    a=max(tmpa,a);
  }
  sort(b,b+n);
  int i=n-1;
  int ans=0;
  while(b[i]>a && i>=0 && h>0){
    ans++;
    h-=b[i--];
  }
  if(h>0)
    ans+=(h+a-1)/a;
  cout<<ans<<endl;
    
    
  return 0;
}
  



  
      
    

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n, w;
  cin >> n >> w;
  ll wt[n+1], v[n+1];
  for(ll i = 1; i < n+1; i++) cin >> wt[i] >> v[i];
  ll m = 0;
  for(ll i = 1; i < n+1; i++) m+=v[i];
  ll dp[n+1][m+1];
  memset(dp, -1, sizeof(dp));
  bool bl[m+1];
  memset(bl, 0, sizeof(bl));
  for(ll i = 1; i < n+1;i++)
  {
    bl[v[i]] = 1;
    if(dp[i][v[i]] == -1) dp[i][v[i]] = wt[i];
    else dp[i][v[i]] = min(wt[i], dp[i][v[i]]);
    if(i == 1) continue;
    for(ll j = 1; j < m+1; j++)
    {
      if(dp[i-1][j] == -1) continue;
      
      if(dp[i][j] == -1) dp[i][j] = dp[i-1][j];
      else dp[i][j] = min(dp[i][j], dp[i-1][j]);
      
      if(dp[i-1][j] + wt[i] > w) continue;
      
      dp[i][j + v[i]] = dp[i-1][j] + wt[i];
      bl[j + v[i]] = 1;
    }
  }
  ll mx = 0;
  for(ll i = 1; i < m+1; i++) if(bl[i] == 1) mx = i;
  cout << mx << endl;

}

Measured memory_bytes: 79232
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int v[3][3];
    for (int i = 0; i < 9; ++i) cin >> v[i/3][i%3];
    
    for (int i = 0; i < 3; ++i) {
        int minVal = min({v[i][0], v[i][1], v[i][2]});
        v[i][0] -= minVal, v[i][1] -= minVal, v[i][2] -= minVal;
    }
    
    for (int i = 0; i < 3; ++i) {
        set<int> check;
        check.insert(v[0][i]), check.insert(v[1][i]), check.insert(v[2][i]);
        if (check.size() != 1) return cout << "No\n", 0;
    }
    
    cout << "Yes\n";
    
    return 0;
}

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

using ll = long long;
#define mod 1000000007
#define init ios::sync_with_stdio(0), cin.tie(0);
typedef vector<int> vi;
typedef pair<int, int> pi;
#define MS(x, y) memset(x, y, sizeof(x))
#define F first
#define S second
#define PB push_back
#define MP make_pair

int main()
{
    init;
    int n;
    cin >> n;

    map<ll, ll> mp;
    ll sum = 0;
    for (ll i = 0; i < n; i++)
    {
        ll x;
        cin >> x;
        mp[x]++;
        sum += x;
    }

    ll q;
    cin >> q;
    // cout << sum << endl;
    while (q--)
    {
        ll x, y;
        cin >> x >> y;
        ll cnt = mp[x];
        sum -= (cnt * x);
        mp[x] = 0;
        sum += (cnt * y);
        mp[y] += cnt;
        cout << sum << '\n';
    }
}

Measured memory_bytes: 9564
#include<iostream>
using namespace std;
int main(){
	int n,m;
	int i,j,k;
	int a,b;
	long long int s=0;
	cin>>n>>m;
	for(i=m+1;i<=n;i++){
		a=n/i,b=n%i;
		s+=a*(i-m);
		if(b>=m){
			s+=b-m;
			if(m!=0)s++;
		}
	}
	cout<<s<<endl;
	return 0;
}


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


public class Main {
 
    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
    private static StringTokenizer st;
 
    public static void main ( String [] args ) throws IOException
    {
    new Main().cal();
    }
 
  
    private void cal() throws IOException 
    {
    int N = Integer.parseInt(br.readLine());
    int [] n = new int[N];
    st = new StringTokenizer(br.readLine());
 
    for(int i = 0; i < N; i++)
        n[i] = Integer.parseInt(st.nextToken());
 
    printArray(n);
    for(int j = 1; j < n.length; j++) {
        int key = n[j];
        int i = j-1;
        while( i >= 0 && n[i] > key ) {
        n[i+1] = n[i];
        i--;
        }
        n[i+1] = key;
 
        printArray(n);
    }
    }
     
    private void printArray(int [] A) {
    for(int i = 0; i < A.length; i++) {
        if ( i > 0 ) System.out.print(" ");
        System.out.print(A[i]);
    }
    System.out.println("");
    }
 
}

Measured memory_bytes: 10000
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define pr pair<int,int>
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int k,a,b; cin>>k>>a>>b;
  for(int i=a;i<=b;i++)
    if(i%k==0){
      cout<<"OK\n";
      return 0;
    }
  cout<<"NG\n";
  return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
int main(void)
{
	int a,b,n;
	scanf("%d %d",&a,&b);
	n = a + b;
	if(n >= 10){
		printf("error\n");
	}
	else if(n < 10){
		printf("%d\n",n);
	}
	return 0;
}

Measured memory_bytes: 128
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.
 
My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.
 
He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.
 
The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/
 
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<setprecision(20);
    cout<<fixed;
    int r=0;
    cin>>r;
    cout<<(2.0*M_PI*r)<<endl;
}


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

int s,w;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>s>>w;
    if (w>=s) cout<<"unsafe";
    else cout<<"safe";
    
    
    
    
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#define MAX 1000001

typedef struct{
  int time;
  char name[10];
} P;

void enqueue(P);
void dequeue(void);
int head=0,tail=0,x;


P queue[MAX];

int main()
{
  int n,q,i,sum=0;  /* q=クオンタム */
  scanf("%d %d",&n,&q);
  tail = n;
  for(i=0 ; i<n ; i++)
  {
    scanf("%s %d",queue[i].name,&queue[i].time);
  }

  while(1)
  {
    if(head == tail) break;
    if(queue[head].time>q)
    {
      sum += q ;
      queue[head].time -= q;
      enqueue(queue[head]);
      dequeue();
    }
    else
    {
      sum += queue[head].time;
      printf("%s %d\n",queue[head].name,sum);
      dequeue();
    }
  }
  return 0;
}

void enqueue(P q)
{
  if(head == (tail + 1)% MAX) exit(1);
  queue[tail]=q;
  if(tail + 1 == MAX) tail=0;
  else tail++;
}

void dequeue(void)
{
  if(head == tail) exit(1);
  if(head + 1 == MAX) head = 0;
  else head++;
}



Measured memory_bytes: 4644
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final String last = in.nextLine();
        System.out.println("ABC".equals(last) ? "ARC" : "ABC");
    }
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N; cin >> N;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	LL sum = accumulate(ALL(a), 0LL);
	LL M; cin >> M;
	FOR(_, 0, M) {
		LL P, X; cin >> P >> X;
		P--;
		LL ans = sum-a[P]+X;
		cout << ans << endl;
	}



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N, X, T, ans;
  cin >> N >> X >> T;
  
  if(N % X == 0){
    ans = N / X * T;
  }
  else{
    ans = (N / X + 1) * T;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
// Problem : B - Ordinary Number
// Contest : AtCoder Beginner Contest 132
// URL : https://atcoder.jp/contests/abc132/tasks/abc132_b
// Memory Limit : 1024,000000 MB 
// Time Limit : 2000,000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <cmath>
#include <cstdio>

#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <map>
#include <set>
#include <vector>

using namespace std;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int n;

vector<int> a;

void input() {
  cin >> n;
  
  a = vector<int>(n);
  for (auto&& i : a)
    cin >> i;
}

void solve1() {
  int ans = 0;
  
  for (int i = 1; i < n - 1; ++i) {
    vector<int> cur = {a[i - 1], a[i], a[i + 1]};
    
    sort(cur.begin(), cur.end());
    
    if (cur[1] == a[i])
      ++ans;
  }
  
  cout << ans;
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve1();
}


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

int main(){
    //kは3変数の範囲、sは3変数の和
    int k, s;
    cin >> k >> s;

    int ans = 0;
    for(int i=0; i<=k; i++){
        for(int j=0; j<=k; j++){
            int z = s - i - j;
            if( 0 <= z && z <= k) ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll mod = 10e9+7;

#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prtd(n, var)  cout << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl


//----------------------------------------------------------------

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

  vector<ll> p(n);
  rep(i,n){
    cin >> p[i];
  }

  vector<ll> sum(n+1);

  sum[0] = 0;
  rep(i,n){
    sum[i+1] = sum[i]+p[i];
  }

  ll ans=-1;
  rep(i,n-k+1){
    if(ans < sum[i+k]-sum[i]){
      ans = sum[i+k]-sum[i];
    }
  }

  prtd(12, double(ans+k)/2.);

}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,x;
    cin>>n>>x;

    vi m(n);
    
    int mn = IINF;
    int sum = 0;
    REP(i,n){
        cin>>m[i];
        chmin(mn,m[i]);
        sum += m[i];
    }

    x -= sum;

    int ans = n;
    ans += x/mn;

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

Measured memory_bytes: 3612
N = gets.to_i
a,ba,b = 0,0,0
ans = 0
N.times do |i|
  s = gets.chomp
  (s.length-1).times do |i|
    ans += 1 if s[i] == "A" && s[i+1] == "B"
  end
  if s[0] == "B" && s[-1] == "A"
    ba += 1
  elsif s[0] == "B"
    b += 1
  elsif s[-1] == "A"
    a += 1
  end
end
ans += [a,b].min
if ba > 0
  ans += ba-1
  ans += 1 if a+b > 0
end
p ans


Measured memory_bytes: 1788
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
#define N 100010
int a[N],b[N],n;
int t[N];
int check(int x)
{
    int s=fabs(a[x]-a[x-1])+fabs(b[x]-b[x-1]);
    if(s>t[x]-t[x-1])
        return 0;
    if((t[x]-s-t[x-1])%2==1)
        return 0;
    return 1;
}
int main()
{
    int i,j,k;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    scanf("%d%d%d",&t[i],&a[i],&b[i]);
    a[0]=0;
    b[0]=0;
    t[0]=0;
    for(i=1;i<=n;i++)
    {
        if(check(i)==0)
            break;
    }
    //printf("%d\n",i);
    if(i==n+1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 1280
IDENTIFICATION DIVISION.
PROGRAM-ID. 166D.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 X          PIC 9(10) COMP.
01 A          PIC S9(3) COMP.
01 B          PIC S9(3) COMP.
01 Y          PIC S9(4) COMP.
01 Z          PIC S9(4) COMP.
01 CNT        PIC 9(18) COMP.
01 OUT1       PIC ---9.
01 OUT2       PIC ---9.
*>
PROCEDURE DIVISION.
  ACCEPT X.
*>
  MOVE 0 TO Y Z.
  PERFORM VARYING A FROM 1 BY 1 UNTIL A > 3980 OR Y > 0
    PERFORM VARYING B FROM -2500 BY 1 UNTIL B > 3980 OR Y > 0  
      IF (X = (A ** 5) - (B ** 5))
         MOVE A TO Y
         MOVE B TO Z
      END-IF 
    END-PERFORM  
  END-PERFORM.  
*>
  MOVE Y TO OUT1
  MOVE Z TO OUT2
  DISPLAY FUNCTION TRIM(OUT1) ' ' FUNCTION TRIM(OUT2).
  STOP RUN.


Measured memory_bytes: 3696