akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)
struct edge{
	ll to,cost;
};
vector<edge> G[3000];
ll d[3000];
ll n,m,k;
const ll INF=0xffffffffff;
priority_queue<P,vector<P>,greater<P> > q;
int main()
{
	cin>>n>>m>>k;
	fill(d,d+n,INF);
	rep(i,m){
		ll x,y,z;
		cin>>x>>y>>z;
		y--;
		x--;
		G[x].pb(edge{y,z});
		G[y].pb(edge{x,z});
	}
	rep(i,k){
		ll x;
		cin>>x;
		d[--x]=0;
		q.push(P(0,x));
	}
	while(!q.empty()){
		P p=q.top();
		q.pop();
		ll x=p.sc;
		if(d[x]<p.fr) continue;
		rep(i,G[x].size()){
			edge e=G[x][i];
			if(d[e.to]>d[x]+e.cost){
				d[e.to]=d[x]+e.cost;
				q.push(P(d[e.to],e.to));
			}
		}
	}
	//rep(i,n) cout<<i+1<<"]= "<<d[i]<<endl;
	ll ans=0;
	rep(i,n){
		rep(j,G[i].size()){
			edge e=G[i][j];
			ll a=d[i],b=d[G[i][j].to];
			if(abs(a-b)>=e.cost){
				ans=max(ans,max(a,b));
			}
			else{
				ans=max(ans,(a+b+e.cost+1)/2);
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8780
#include <stdio.h>

int main(void)
{
    int a, b, c, x;
    scanf("%d%d%d", &x, &a, &b);
    c = b - a;
    if (c <= 0) printf("delicious\n");
    else if (c <= x) printf("safe\n");
    else printf("dangerous\n");
    return 0;
}


Measured memory_bytes: 128
N = int(input())
S = input()

chars = "abcdefghijklmnopqrstuvwxyz" + "abcdefghijklmnopqrstuvwxyz"
chars = chars.upper()
dic = {chars[i]: chars[i+N] for i in range(26)}
ans = ""
for i in range(len(S)):
    ans += dic[S[i]]

print(ans)

Measured memory_bytes: 67380
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define endl '\n'
#define ll long long
#define mod 1000000007
#define inf 1000000000000000000
vector<ll> adj[100002];
ll ans=0;
ll co;
void dfs(ll v,ll p)
{
	ll count=0;
	for(ll i:adj[v])
	{
		if(i!=p)
		{
			if(p==-1)
				ans=(ans*(co-1-count))%mod;
			else
				ans=(ans*(co-2-count))%mod;
			count++;
			dfs(i,v);
		}
	}
}
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	ll n,k,a,b;
	cin>>n>>k;
	for(ll i=1;i<n;i++)
	{
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	co=k;
	ans=k%mod;
	dfs(1,-1);
	cout<<ans<<endl;
	return 0;
}





Measured memory_bytes: 10368
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input().rstrip())

tb = {'r': p, 's': r, 'p': s}
ans = 0
for i in range(len(t)):
    if i < k:
        ans += tb[t[i]]
    else:
        if t[i - k] == t[i]:
            t[i] = '-'
        else:
            ans += tb[t[i]]
print(ans)


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

typedef long long int ll;
ll gcd(ll a, ll b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
} 
int main() {
    ll n;
    cin>>n;
    vector<pair<ll,ll> > v;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(b,a));
    }
    sort(v.begin(),v.end());
    ll s=0;
    for(int i=0;i<n;i++){
        s+=v[i].second;
        if(s>v[i].first){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

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

int dp[100001];

int getRes(int a[],int n){
	if(dp[n]!=-1)
	  return dp[n];
	int n1 = getRes(a,n-1);
	int n2 = getRes(a,n-2);
	return dp[n] = min(abs(a[n]-a[n-1])+n1, abs(a[n]-a[n-2])+n2);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// your code goes here
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	 cin>>a[i];
	if(n==1){
		cout<<0<<endl;
		return 0;
	}
	memset(dp,-1,sizeof(a[0])*100001);
    dp[0] = 0;
    dp[1] = abs(a[0]-a[1]);
    cout<<getRes(a,n-1)<<endl;
	return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

const string DIRS = "URDL", TANK = "^>v<";
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};

bool in_range(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

int T, H, W, N, tx, ty;
string grid[22], opr;

void move(int d) {
	int nx = tx + dx[d], ny = ty + dy[d];
	if (!in_range(nx, ny, W, H) || grid[ny][nx] != '.') nx = tx, ny = ty;
	grid[ty][tx] = '.';
	grid[ny][nx] = TANK[d];
	ty = ny; tx = nx;
}

void shoot() {
	int d = TANK.find(grid[ty][tx]);
	int x = tx + dx[d], y = ty + dy[d];
	
	while (in_range(x, y, W, H) && grid[y][x] != '#' && grid[y][x] != '*') {
		x += dx[d];
		y += dy[d];
	}
	
	if (in_range(x, y, W, H) && grid[y][x] == '*') grid[y][x] = '.';
}

void simulate() {
	for_(i,0,N) {
		char c = opr[i];
		if (c == 'S') shoot();
		else move((int)DIRS.find(c));
	}
}

int main() {
	cin >> T;
	
	for_(case_num,0,T) {
		cin >> H >> W;
		
		for_(y,0,H) {
			cin >> grid[y];
			for_(x,0,W) if (TANK.find(grid[y][x]) != TANK.npos) tx = x, ty = y;
		}
		
		cin >> N;
		cin >> opr;
		
		simulate();
		
		for_(y,0,H) cout << grid[y] << endl;
		if (case_num < T - 1) cout << endl;
	}
}

Measured memory_bytes: 1208
#include <iostream>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

int N, M;
bool ac[100010];
ll cnt[100010];

int main()
{
  std::cin >> N >> M;

  rep( i, M )
  {
    int p;
    std::string S;

    std::cin >> p >> S;

    --p;

    if( S == "AC" )
      ac[p] = true;
    else
    {
      if( !ac[p] )
        ++cnt[p];
    }
  }

  ll ans1 = 0, ans2 = 0;
  rep( i, N )
  {
    if( ac[i] )
    {
      ++ans1;
      ans2 += cnt[i];
    }
  }

  printf( "%lld %lld\n", ans1, ans2 );

  return 0;
}

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

int main(){
  int N,K;
  int i,j;
  cin >> N >> K;
  vector<int> d(N);
  vector<int> h(N);
  for(i=0;i<N;i++){
    cin >> h[i];
    d[i] = INT_MAX;
  }
  
  d[0] = 0;
  for(i=1;i<N;i++)
    for(j=max(0, i-K);j<i;j++)
	  d[i] = min(d[i], d[j]+abs(h[i]-h[j]));
  
  std::cout << d[N-1];
  
  return 0;
}


Measured memory_bytes: 3920
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <deque>
#include <complex>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
typedef complex<int> cl;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1},INF=1<<30;
const char color[]{'R','G','B'};
int x,y,W,H;
char maps[10][10]={};
bool draw(bool same[10][10]){
	bool searched[10][10]={};
	bool ans=false;
	searched[0][0]=1;
	queue<cl> qu;
	qu.push(cl(0,0));
	while(!qu.empty()){
		int w=qu.front().real(),h=qu.front().imag();
		qu.pop();
		REP(i,4){
		int nx=w+dx[i],ny=h+dy[i];
			if(nx<W&&ny<H&&nx>=0&&ny>=0)
				if((maps[ny][nx]==maps[0][0]||same[ny][nx])&& !searched[ny][nx]){
					if(!same[ny][nx])
					ans=true;
					same[ny][nx]=true;
					qu.push(cl(nx,ny));
					searched[ny][nx]=true;
				}
		}
	}
	return ans;
}
int search(bool chan[10][10],int minium=INF){
	char f=maps[0][0];
	bool ans=true;
	REP(i,y) REP(j,x) if(!chan[i][j]) ans=false;
	if(ans) return 0;
	if(minium==0)
	return 1;
	REP(i,3){
		if(color[i]==maps[0][0]) continue;
		bool same[10][10]={};
		REP(j,10) REP(k,10) same[j][k]=chan[j][k];
		maps[0][0]=color[i];
		if(draw(same))
		minium=min(minium,search(same,minium-1));
		maps[0][0]=f;
	}
	return minium+1;
}
int main() {
	// your code goes here
	while(cin >> x >> y && x){
	W=x;
	H=y;
	REP(i,y) REP(j,x) cin >> maps[i][j];
	bool chan[10][10]={};
	chan[0][0]=1;
	draw(chan);
	cout << search(chan) << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
N = int(input())
A = list(str(input()))
B = list(str(input()))
C = list(str(input()))

count = 0
for i in range(N):
	if(A[i]==B[i] and B[i]!=C[i]):
		count += 1
	elif(A[i]==C[i] and C[i]!=B[i]):
		count += 1
	elif(B[i]==A[i] and A[i]!=C[i]):
		count += 1
	elif(B[i]==C[i] and C[i]!=A[i]):
		count += 1
	elif(C[i]==A[i] and A[i]!=B[i]):
		count += 1
	elif(C[i]==B[i] and B[i]!=A[i]):
		count += 1
	elif(A[i]!=B[i] and B[i]!=C[i]):
		count += 2

print(count)

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

string S;
int Q;
int n = 0;  //反転回数
vector<char> l;
vector<char> r;
int T, F;
char C;


int main(){
  cin >> S >> Q;

  for(int i = 0; i < Q; i++){
    cin >> T;
    if(T == 1) ++n;
    else if(T == 2){
      cin >> F >> C;
      if(F == 1){
        if(n & 1) r.push_back(C);
        else l.push_back(C);
      }else if(F == 2){
        if(n & 1) l.push_back(C);
        else r.push_back(C);
      }
    }
  }

  if(n & 1){
    for(int i = r.size()-1; i >= 0; i--) cout << r[i];
    reverse(S.begin(), S.end());
    cout << S;
    for(int i = 0; i < l.size(); i++) cout << l[i];
    cout << endl;
  }else{
    for(int i = l.size()-1; i >= 0; i--) cout << l[i];
    cout << S;
    for(int i = 0; i < r.size(); i++) cout << r[i];
    cout << endl;
  }

  return 0;

}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
#define PI 3.1415926535897932384626433832795028
#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

Int x_1, y_1, x_2, y_2;
Int n;
Int x[216000], y[216000];
vector<P> nums;
int main(){
  cin >> x_1 >> y_1 >> x_2 >> y_2;
  if(x_1 > x_2){
    swap(x_1, x_2);
    swap(y_1, y_2);
  }
  cin >> n;
  for(int i = 0;i < n;i++)cin >> x[i] >> y[i];

  if(y_1 > y_2){
    y_1 = -y_1;
    y_2 = -y_2;
    for(int i = 0;i < n;i++)y[i] *= -1;
  }

  for(int i = 0;i < n;i++){
    if(x[i] < x_1 || x_2 < x[i])continue;
    if(y[i] < y_1 || y_2 < y[i])continue;
    nums.push_back(P(x[i], y[i]));
  }
  sort(nums.begin(), nums.end());
  vector<int> dp(n, INF);
  for(int i = 0;i < nums.size();i++){
    int val = nums[i].second;
    *upper_bound(dp.begin(), dp.end(), val) = val;
  }
  int cnt = 0;
  while(cnt < n && dp[cnt] != INF)cnt++;
  double ans;
  ans = (x_2 - x_1 + y_2 - y_1) * 100 + cnt * (5 * PI - 20);
  
  if(min(x_2 - x_1,y_2- y_1) + 1 == cnt){
    ans -= 5 * PI - 20;
    ans += 10 * PI - 20;
  }

  printf("%.10lf\n", ans);
  
  return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
  string s;
  cin >> s;

  int length = s.length();

  rep(i, length / 2 + 1) {
    if (s[i] != s[length - i -1]) {
        cout << "No" << endl;
        return 0;
    }
  }

  length = (length - 1) / 2;

  rep(i, (length - 1) / 2 + 1) {
    if (s[i] != s[length - i - 1]) {
        cout << "No" << endl;
        return 0;
    }
  }

  length = s.length();
  for(int i = (length + 3) / 2 - 1; i < (2 * length + 3) / 4 + 1; i++) {
    if (s[i] != s[length - i - 1]) {
        cout << "No" << endl;
        return 0;
    }
  }

  cout << "Yes" << endl;
  

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n)  RFOR(i,0,n)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
#define P pair<int,int>
#define PPi pair<P,int>
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int N;
	vector<int> ve;
	string S1,S2;
	cin>>N>>S1>>S2;

	REP(i,N){
		if(S1[i]!=S2[i]){
			i+=1; ve.pb(1);//横置き
		}else{
			ve.pb(2);//縦置き
		}
	}

	ll result=3;
	if(ve[0]==1) result*=2;

	FOR(i,1,ve.size()){
		if(ve[i-1]==2) result=(result*2)%MOD;
		else if(ve[i-1]==1&&ve[i]==1) result=(result*3)%MOD;
	}
	print(result);

	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
#include<iomanip>
using namespace std;
string S, U[1000];
stack<double>T; int cnt;double a, b;
int main() {
	while (getline(cin, S)) {
		for (int i = 0; i < 1000; i++) { U[i] = ""; }
		cnt = 0;
		for (int i = 0; i < S.size(); i++) {
			if (S[i] == ' ') { cnt++; }
			else { U[cnt] += S[i]; }
		}
		cnt++;
		for (int i = 0; i < cnt; i++) {
			if (U[i] == "+") {
				a = T.top();
				T.pop();
				b = T.top();
				T.pop();
				T.push(a + b);
			}
			else if (U[i] == "-") {
				a = T.top();
				T.pop();
				b = T.top();
				T.pop();
				T.push(b - a);
			}
			else if (U[i] == "*") {
				a = T.top();
				T.pop();
				b = T.top();
				T.pop();
				T.push(a * b);
			}
			else if (U[i] == "/") {
				a = T.top();
				T.pop();
				b = T.top();
				T.pop();
				T.push(b / a);
			}
			else {
				T.push(stoi(U[i]));
			}
		}
		cout << fixed << setprecision(20) << T.top() << endl;
		T.pop();
	}
}

Measured memory_bytes: 3252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException {
		Scanner stdIn = new Scanner(System.in);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String A = br.readLine();
		char[] B = A.toCharArray();
		
		
		for(int i = 0; i < B.length; i++) {
			if(Character.isLowerCase(B[i])) {
				B[i] = Character.toUpperCase(B[i]);
			}
			else if (Character.isUpperCase(B[i])) {
				B[i] = Character.toLowerCase(B[i]);
			}
		}
		
		A = new String(B);
		
		System.out.println(A);
	}
}

Measured memory_bytes: 17156
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let s: Vec<i32> = s.trim().split(' ').map(|x| x.parse::<i32>().unwrap()).collect();

    if s[0] > s[1] {
        println!("safe");
    } else {
        println!("unsafe");
    }
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL N,M;
  cin >> N >> M;

  vector<vector<bool>> swi(M, vector<bool>(N, false));
  REP(i,M){
    LL k;
    cin >> k;
    REP(j,k){
      LL ss;
      cin >> ss;
      swi[i][ss - 1] = true;
    }
  }

  vector<LL> p(M);

  REP(i,M){
    cin >> p[i];
  }

  LL cnt = 0;
  REP(i,1<<N){
    bool flag = true;
    REP(j,M){
      LL d = 0;
      REP(k, N)
      {
        if(swi[j][k]){
          if((i&(1<<k))>0){
            d++;
          }
        }
      }
      if(d%2!=p[j]){
        flag = false;
      }
    }
    if(flag){
      cnt++;
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	lint N;
	cin >> N;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	rep(i, N) {
		if (A[i] % 2 != 0) {
			cout << "first" << endl;
			return 0;
		}
	}
	cout << "second" << endl;
}

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

int main() {
	string N;
	cin >> N;
	if (N.at(0) == '9') {
		cout << "Yes" << endl;
	}
	else if (N.at(1) == '9') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;

    vector<vector<int>> s_dict(26, vector<int>(0));
    for (int i = 0; i < static_cast<int>(s.size()); i++) {
        s_dict[s[i] - 'a'].push_back(i);
    }

    long long r = 0;
    for (int s_idx = 0, t_idx = 0; t_idx < static_cast<int>(t.size()); ) {
        vector<int>::iterator ite = lower_bound(s_dict[t[t_idx] - 'a'].begin(), s_dict[t[t_idx] - 'a'].end(), s_idx);
        if (ite == s_dict[t[t_idx] - 'a'].end()) {
            if (s_idx == 0) {
                r = -1;
                break;
            }

            r += s.size() - s_idx;
            s_idx = 0;
        } else {
            r += *ite - s_idx + 1;
            s_idx = *ite + 1;

            if (s_idx == static_cast<int>(s.size())) {
                s_idx = 0;
            }

            t_idx++;
        }
    }

    cout << r << endl;
}


Measured memory_bytes: 1216
S = input()
s_reverse = S[::-1]

dp = [0]*2019
now_sum = 0
ten_times = 1

for ch in s_reverse:
    now_sum = (now_sum + int(ch)*ten_times) % 2019
    ten_times = (ten_times * 10) % 2019
    dp[now_sum] += 1

ans = dp[0]
for i_dp in dp:
    ans += i_dp*(i_dp-1)//2

print(ans)

Measured memory_bytes: 68512
import sys

a, b = sys.stdin.read().split()

def main():
    la = len(a)
    lb = len(b)
    if la > lb:
        return 'GREATER'
    elif la < lb:
        return 'LESS'
    else:
        for i in range(la):
            if a[i] > b[i]:
                return 'GREATER'
            elif a[i] < b[i]:
                return 'LESS'
        return 'EQUAL'
                
if __name__ == '__main__':
    ans = main()
    print(ans)

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

int main(){
  int m,d,d1,d2,ans=0,i,j;
  cin >> m >> d;
  for(j=1; j<=m; j++){
  for(i=22; i<=d; i++){
    d1=i/10; d2=i%10;
    if(j==d1*d2 && d2>=2){
      ans++;
    }
  }
    
  }
  cout << ans;
}

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

int main(){
    using namespace std;
    // input
    size_t n;
    cin >> n;
    
    // process
    long ans{-1000000001}, mn;
    cin >> mn;
    for(long i = 1, a; i < n; ++i){
        cin >> a;
        ans = max(ans, a - mn);
        mn = min(a, mn);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<double> r(n);
	for(int i=0; i<n; i++){
		cin >> r[i];
	}
	vector<double> c(n, 0);
	c[0] = r[0];
	double right = r[0]*2;
	for(int i=1; i<n; i++){
		for(int j=0; j<i; j++){
			c[i] = max(c[i], c[j] +sqrt((r[i]+r[j])*(r[i]+r[j]) -abs((r[j]-r[i])*(r[j]-r[i]))));
		}
		if(c[i] < r[i]) c[i] = r[i];
		right = max(right, c[i]+r[i]);
	}
	cout << fixed << setprecision(10);
	cout << right << endl;
    return 0;
}


Measured memory_bytes: 3296
// inputに入力データ全体が入る
function Main(input) {
	var line = input.split("\n");
	var A = Number(line[0]);
	var B = Number(line[1]);
	var C = Number(line[2]);
	var D = Number(line[3]);

	var train = A < B ? A : B;
	var bus = C < D ? C : D;
	console.log(train+bus);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 15180
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
 
const int MAX = 5;
const long long INF = 1LL << 60;
 
int main(){
    long long N;
    long long X[MAX];
    long long m = INF;
    long long ans = 0;
 
    cin >> N;
    for(int i = 0;i < MAX;i++){
        cin >> X[i];
        m = min(X[i],m);
    }
 
    cout << (4LL + ((N + m - 1LL) / m)) << endl;
 
    return 0;
}

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

int main() {
	std::string s;
	std::cin >> s;
	int n = 0;
	for (int i = 0;i < s.size();i++) {
		if (s[i] == 'A') {
			if (s[i + 1] == 'C') {
				std::cout << "Yes" << std::endl;
				n += 1;
				break;
			}
		}
	}
	if (n == 0) {
		std::cout << "No" << std::endl;
	}

	return 0;
}

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

#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

void solve()
{
  string s;cin>>s;
  ll k; cin>>k;

  char ans='1';
  for (ll i=0; i<min((ll)SZ(s),k); i++) {
    if (s[i] >= '2') {
      ans = s[i];
      break;
    }
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<cstdio>  
#include<iostream>  
#include<algorithm>  
#include<cstdlib>  
#include<cstring>
#include<string>
#include<climits>
#include<vector>
#include<cmath>
#include<map>
#define LL long long
#define pii pair<int,int>
#define mp make_pair
 
using namespace std;
 
inline char nc(){
	/*
  static char buf[100000],*p1=buf,*p2=buf;
  if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; }
  return *p1++;
  	*/return getchar();
}
 
inline void read(int &x){
  char c=nc();int b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
 
inline void read(LL &x){
  char c=nc();LL b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}

inline int read(char *s)
{
	char c=nc();int len=1;
	for(;!(c>='a' && c<='z');c=nc()) if (c==EOF) return 0;
	for(;(c>='a' && c<='z');s[len++]=c,c=nc());
	s[len++]='\0';
	return len;
}

inline void read(char &x){
  for (x=nc();!(x>='A' && x<='Z');x=nc());
}

int wt,ss[19];
inline void print(int x){
	if (x<0) x=-x,putchar('-'); 
	if (!x) putchar(48); else {
	for (wt=0;x;ss[++wt]=x%10,x/=10);
	for (;wt;putchar(ss[wt]+48),wt--);}
}
inline void print(LL x){
	if (x<0) x=-x,putchar('-');
	if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}
}

int n,m;
char s[110],t[110],p[210];

bool check(int x)
{
	for (int i=1;i<=n;i++)
		if (s[i]!=p[i]) return false;
	return true;
}

int main()
{
	n=read(s),n=strlen(s+1);
	m=read(t);int x=0;
	for (int i=n;i<=n+n;i++)
	{
		for (int j=1;j<=i-n;j++)
			p[j]=s[j];
		for (int j=1;j<=n;j++)
			p[(i-n)+j]=t[j];
		if (check(i)) {print(i),puts("");return 0;}
	}
	return 0;
}

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

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
} comb(100005);

int main() {
  int n, p, a, odd = 0;
  cin >> n >> p;
  rep(i, n) {
    cin >> a;
    if (a % 2 == 1) odd++;
  }

  if (odd == 0) {
    if (p == 0) {
      printf("%lld\n", (ll)pow(2, n));
    } else {
      printf("0\n");
    }
  } else {
    printf("%lld\n", (ll)pow(2, n - 1));
  }
  return 0;
}


Measured memory_bytes: 1792
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d;
  cin>>a>>b>>c>>d;
  int sum,sum2;
  sum=a+b;
  sum2=c+d;
  if(sum>sum2){
    cout<<"Left"<<'\n';
  }
  else if(sum<sum2){
    cout<<"Right"<<'\n';
  }
  else{
    cout<<"Balanced"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

int Compare(pair<int, pair<int, int>> first,
  pair<int, pair<int, int>> second) {
  return first.second < second.second;
}

int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  vector<pair<int, pair<int, int>>> C(M);
  for (int i = 0; i < M; i++) {
    C[i].first = i;
    scanf("%d%d", &C[i].second.first, &C[i].second.second);
  }

  sort(C.begin(), C.end(), Compare);
  int p = 0, x = 1;
  for (int i = 0; i < M; i++) {
    if (C[i].second.first != p) {
      p = C[i].second.first;
      x = 1;
    }
    C[i].second.second = x;
    x++;
  }

  sort(C.begin(), C.end());
  for (int i = 0; i < M; i++) printf("%06d%06d\n", C[i].second.first, C[i].second.second);
}

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

namespace AtCoder.Contest.B
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			var t = int.Parse(cin.Next() + cin.Next());
            if (Math.Sqrt(t) % 1 == 0) Console.WriteLine("Yes");
            else Console.WriteLine("No");

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	lnt n;
	std::cin >> n;
	lnt ans=0;
	for(lnt i=1;i<=n;i++) {
		ans+=n/i*(n/i+1)*i/2;
	}
	print(ans);
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end()))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int h[22000];
int hl[22000], hr[22000];
string S;
signed main() {
    cin >> S;
    N = S.length();
    rep(i, N) {
        h[i + 1] = h[i];
        if (S[i] == '/') { h[i + 1]++; }
        else if (S[i] == '\\') { h[i + 1]--; }
    }
    hl[0] = h[0];
    rep(i, N) { hl[i + 1] = max(hl[i], h[i + 1]); }
    hr[N] = h[N];
    for (int i = N; i > 0; i--) { hr[i - 1] = max(hr[i], h[i - 1]); }
    vint A;
    rep(i, N) {
        int d = min(hl[i], hr[i + 1]);
        int c = max(0LL, 2 * d - h[i] - h[i + 1]);
        if (S[i] == '\\' && c == 1) { A.push_back(c); }
        else if (c > 0) { A.back() += c; }
    }
    rep(i, A.size()) { A[i] /= 2; }
    cout << accumulate(all(A), 0) << endl;
    cout << A.size();
    rep(i, A.size()) { cout << " " << A[i]; }
    cout << endl;
}


Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 1 << 21;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())
int main(void) {
	int N;
	long long M,t1,t2=0,ans;
	std::cin >> N >> M;
	ans = M;
	for (int i =0 ; i < N; ++i) {
		std::cin >> t1;
		ans += std::min(M, t1 - t2);
		t2 = t1;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
const int maxn = 200010;
int main()
{
	char s[maxn];
	int mp[maxn] = { 0 }, ans = 0;
	cin >> s;
	int len = strlen(s);
	mp[0] = 1;
	int x = 0, cnt = 1;
	for (int i = len - 1; i >= 0; i--)
	{
		x = ((s[i] - '0') * cnt + x) % 2019;
		ans += mp[x];
		mp[x]++;
		cnt = cnt * 10 % 2019;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4580
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
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;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    string s;
    cin >> s;

    for(int i = 0; i < s.size(); i++){
        if(s[i] + n > 'Z'){
            s[i] = 'A' - 1 + (s[i] + n) - 'Z'; 
        } else {
            s[i] += n;
        }
    }

    cout << s << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{ 
        
    public static void main(String[] args){
      
        Scanner sc = new Scanner(System.in);
       
        int a[] = new int[26];
        
        String S = sc.next();
        
        for(int i = 0;i < S.length();i++){
            a[S.charAt(i) - 'a']++;
        }
                
        int index = -1;
        
        for(int i = 0; i < 26;i++){
            if(a[i] == 0){
                  index = i;
                  break;
            }            
        }
        
        System.out.println(index == -1 ? "None":(char)('a' + index));        
               
    }    
}       


        

Measured memory_bytes: 23636
#include <stdio.h>

int main(){
   int H, W, iH, iW;
   char symbol;
   while(scanf("%d %d\n",&H,&W)==2){
      if(H==0&&W==0) break;
      for(iH=0;iH<H;iH++){
         for(iW=0;iW<W;iW++){
            if(iH==0||iH==H-1||iW==0||iW==W-1) symbol='#';
            else symbol='.';
            printf("%c",symbol);
         }
         printf("\n");
      }
      printf("\n");
   }
   return 0;
}

Measured memory_bytes: 576
def f(a,b,c)
h=a[0]
t=a[1..-1]
a==[]||h>b[-1]&&f(t,b+[h],c)||h>c[-1]&&f(t,b,c+[h])
end
gets.to_i.times{puts f(gets.split.map(&:to_i),[0],[0])?:YES: :NO}

Measured memory_bytes: 6112
#include <stdio.h>
#include <math.h>
main(){
  int i,j,n,code;
  char cm[7],op,dict[262145];
  for(i=0,scanf("%d %s",&n,cm);i<n;i++,scanf("%s",cm)){
    for(j=code=op=0;op!='\n';scanf("%c",&op))
      if(op=='A') code+=1*pow(4,j++);
      else if(op=='C') code+=2*pow(4,j++);
      else if(op=='G') code+=3*pow(4,j++);
      else if(op=='T') code+=4*pow(4,j++);
    cm[0]=='i'?dict[code]=1:(dict[code]?printf("yes\n"):printf("no\n"));
  }
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld; 


#define F first
#define S second
#define pob pop_back
#define pb push_back
#define Time()	cerr << clock() * 1000 / CLOCKS_PER_SEC << "ms\n"
#define show(x)	cerr << #x << " = " << (x) << '\n'
#define inf 1e14
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define invec(v) for(auto& x : v)cin>>x;
#define Test int T;cin>>T;while(T--)
#define vec vector<ll> 
#define REP(i,j,k) for(int i=(j);(i)<(k);(i)++)
#define phi ((1+sqrt(5))/2)
#define endl '\n'



int main(){
	size_t n;
	cin>>n;
	size_t ans=0,i;
	for(i=1;i<=n;i++){
		if(i%3==0 || i%5==0)continue;
		ans+=i;
	}
	cout<<ans;
	
}


Measured memory_bytes: 3608
# coding: utf-8
import sys
from collections import deque

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def main():
    # 左からgreedyに
    N, D, A = lr()
    monsters = []
    for _ in range(N):
        x, h = lr()
        monsters.append((x, h))

    monsters.sort()
    bomb = deque()
    answer = 0
    attack = 0
    for x, h in monsters:
        while bomb:
            if bomb[0][0] + D < x:
                attack -= bomb[0][1]
                bomb.popleft()
            else:
                break
        h -= attack
        if h > 0:
            t = -(-h//A)
            answer += t
            bomb.append((x + D, A * t))
            attack += A * t

    print(answer)

if __name__ == '__main__':
    main()


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

template <class Abel> struct BIT {
    vector<Abel> dat;
    Abel UNITY_SUM = 0;						// to be set
    
    /* [1, n] */
    BIT(int n) : dat(n + 1, UNITY_SUM) { }
    void init(int n) { dat.sssign(n + 1, UNITY_SUM); }
    
    /* a is 1-indexed */
    inline void add(int a, Abel x) {
        for (int i = a; i < (int)dat.size(); i += i & -i)
            dat[i] = dat[i] + x;
    }
    
    /* [1, a], a is 1-indexed */
    inline Abel sum(int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i)
            res = res + dat[i];
        return res;
    }

    /* [a, b), a and b are 1-indexed */
    inline Abel sum(int a, int b) {
        return sum(b - 1) - sum(a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat.size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int N, M, Q;
typedef pair<int,int> pint;
typedef pair<pint,int> ipint;
vector<ipint> ins;
vector<int> alts;

bool cmp(ipint a, ipint b) {
    return make_pair(a.first.second, a.second) < make_pair(b.first.second, b.second);
}

int main() {
    // 入力受け取り、区間終点ソート、座標圧縮
    cin >> N >> M >> Q;
    ins.resize(M + Q);
    alts.clear();
    for (int i = 0; i < M + Q; ++i) {
        cin >> ins[i].first.first >> ins[i].first.second;
        ++ins[i].first.second;
        if (i < M) ins[i].second = -1; else ins[i].second = i - M;
        alts.push_back(ins[i].first.first), alts.push_back(ins[i].first.second);
    }
    sort(alts.begin(), alts.end());
    alts.erase(unique(alts.begin(), alts.end()), alts.end());
    sort(ins.begin(), ins.end(), cmp);
    
    // 座標圧縮
    for (int i = 0; i < M + Q; ++i) {
        int left = lower_bound(alts.begin(), alts.end(), ins[i].first.first) - alts.begin();
        int right = lower_bound(alts.begin(), alts.end(), ins[i].first.second) - alts.begin();
        ins[i].first.first = left + 1;
        ins[i].first.second = right + 1;
    }

    // 平面走査
    BIT<int> bit( (M+Q)*2 + 10 );
    vector<int> res(Q);
    for (int i = 0; i < M + Q; ++i) {
        if (ins[i].second == -1) bit.add(ins[i].first.first, 1);
        else res[ins[i].second] = bit.sum(ins[i].first.first, ins[i].first.second);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}


Measured memory_bytes: 10860
#include <bits/stdc++.h>
 
using namespace std;
 
int idx,S;
 
bool parse(const string &s){
    if(idx == (int)s.size()) return true;
    idx++;
    bool l,r,res;
    switch(s[idx]){
    case 'T':
	return true;
    case 'F':
	return false;
    case '-':
	return !parse(s);
    case '(':
	l = parse(s);
	idx++;
	if(s[idx] == '+'){
	    r = parse(s);
	    res = l | r;
	}else if(s[idx] == '*'){
	    r = parse(s);
	    res = l & r; 
	}else{
	    idx++;
	    r = parse(s);
	    res = !l || (l && r);
	}
	idx++;
	return res;
    default:
	return ((S >> (s[idx]-'a')) & 1);
    }
}
 
bool solve(const string &s){
    int eq = s.find('=');
    string l = s.substr(0,eq);
    string r = s.substr(eq+1);
    for(S = 0 ; S < (1<<11) ; S++){
	idx = -1;
	bool ll = parse(l);
	idx = -1;
	if(ll != parse(r)){
	    return false;
	}
    }
    return true;
}
 
int main(){
    string s;
    while(cin >> s, s != "#"){
	cout << (solve(s) ? "YES" : "NO") << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        if (s == "AC") ac++;
        if (s == "WA") wa++;
        if (s == "TLE") tle++;
        if (s == "RE") re++;
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}

Measured memory_bytes: 6424
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ){
    if ( L[i].value <= R[j].value ){
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}
 
void mergeSort(struct Card F[], int n, int left, int right ){
  int mid;
  if ( left+1 < right ){
    mid = (left + right)/2;
    mergeSort(F, n, left, mid);
    mergeSort(F, n, mid, right);
    merge(F, n, left, mid, right);
  }
}

int partition(struct Card V[], int n, int p, int r){
  int i, j;
  struct Card t, x;
  x = V[r];
  i = p - 1;
  for ( j = p; j < r; j++ ){
    if ( V[j].value <= x.value ){
      i++;
      t = V[i];
      V[i] = V[j]; 
      V[j] = t;
    }
  }
  t = V[i+1];
  V[i+1] = V[r];
  V[r] = t;
  return i+1;
}

void quickSort(struct Card K[], int n, int p, int r){
  int q;
  if ( p < r ){
    q = partition(K, n, p, r);
    quickSort(K, n, p, q - 1);
    quickSort(K, n, q + 1, r);
  }
}

int main(){
  int n, i, v;
  struct Card U[MAX], T[MAX];
  char S[10];
  int stable = 1;
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    scanf("%s %d", S, &v);
    U[i].suit = T[i].suit = S[0];
    U[i].value = T[i].value = v;
  }

  mergeSort(U, n, 0, n);
  quickSort(T, n, 0, n-1);

  for ( i = 0; i < n; i++ ){
    if ( U[i].suit != T[i].suit ) stable = 0;
  }

  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for ( i = 0; i < n; i++ ) {
    printf("%c %d\n", T[i].suit, T[i].value);
  }
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
  long long a,b;
  cin >> a >> b;
  if(a*b<=0){
    cout << "Zero" << endl;
  }else if(a>0&&b>0){
    cout << "Positive" << endl;
  }else{
    if((b-a)%2==0){
      cout << "Negative" << endl;
    }else{
      cout << "Positive" << endl;
    }
  }
}


Measured memory_bytes: 256
import scala.io.{StdIn => in}

object Main extends App {
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)

  val ans = (n , m) match {
    case (1, 1) => 1L
    case (a, b) if a == 2 || b == 2 => 0L
    case (a, b) if a == 1 && b != 1 => m - 2L
    case (a, b) if a != 1 && b == 1 => n - 2L
    case _ => (n-2L) * (m-2L)
  }

  println(ans)
}


Measured memory_bytes: 25408
// 解答不能.
// 以下のソースコードを勉強する.
// pekempey氏.
// https://atcoder.jp/contests/abc141/submissions/7522428
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;
char c[5005];

int main(){
    int N;
    scanf("%d %s", &N, c);
    string S(c);
    vector<vector<int>> lcp(N + 1, vector<int>(N + 1));
    int ans = 0;
    repr(i, N){
        repr(j, N){
            if(S[i] != S[j]) lcp[i][j] = 0;
            else             lcp[i][j] = lcp[i + 1][j + 1] + 1;
            if(i < j) ans = max(ans, min(j - i, lcp[i][j]));
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 100012