akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define F(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define FD(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define pii pair<int,int>
#define reset(x,y) memset(x, y,sizeof(x))
#define MIN(x,y) if (x > (y)) x = (y)
#define MAX(x,y) if (x < (y)) x = (y)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define EL putchar('\n');
#define mod 1000000007
#define oo 300
int read()
{
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
void write(int x)
{
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}
int n;
int a[oo],mina=1e6;
int f[100005],k;
void ReadInPut()
{
    n=read();
    k=read();
    F(i,1,n){a[i]=read();MIN(mina,a[i]);}
    if(n==1)
    {
        if((k/a[1])%2)cout<<"First";
        else cout<<"Second";
        exit(0);
    }
}
void Solve()
{
    F(i,mina,k)
    {
        int ok=0;
        F(j,1,n)
        {
            if(i<a[j])continue;
            ok=1-f[i-a[j]];
            if(ok)break;
        }
        f[i]=ok;
    }
    if(f[k])cout<<"First";
    else cout<<"Second";
}
main()
{
//    freopen("t.INP","r",stdin);
  //  freopen(".OUT","w",stdout);
    int sotest=1;
    //cin>>sotest;
    for(int i=1;i<=sotest;i++)
    {
        ReadInPut();
        Solve();
    }
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int N,a,b,c;
	scanf("%d",&N);
	while(N--){
		scanf("%d %d %d",&a,&b,&c);
		if(a*a+b*b==c*c || a*a+c*c==b*b || b*b+c*c==a*a)puts("YES");
		else puts("NO");
	}
	return 0;
}

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

int main()
{
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  int k;
  cin>>k;
  
  cout<<a[k-1]<<"\n";
  return 0;
}

Measured memory_bytes: 256
/*
* Author. Silviase(@silviasetitech)
* For AtCoder
*/

import java.util.*;
import java.lang.*;
import java.math.*;


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



        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(Math.min(c, b/a));


        
        sc.close();
    }


    public static long gcd(Long m, long n) {
        if(m < n) {
            return gcd(n, m);
        }
        if(n == 0){
            return m;
        } 
        return gcd(n, m % n);
    }

    public static long[][] Combination_nCk(long n, long k) {
        n++; k++;
        long[][] ans = new long[(int)n][(int)k];
        for (int i = 0; i < n; i++) {
            ans[i][0] = 1;
        }
        for (int i = 0; i < n-1; i++) {
            for (int j = 0; j < k-1; j++) {
                if (i < j) {
                    ans[i][j] = 0;
                }else{
                    ans[i+1][j+1] = ans[i][j] + ans[i][j+1];
                }
            }
        }
        return ans;
    }

    public static double[][] Probability_nCk(int n, int k) {
        n++; k++;
        double[][] ans = new double[n][k];
        for (int i = 0; i < n; i++) {
            if (i == 0) {
                ans[i][0] = 1;
            }else{
                ans[i][0] = ans[i-1][0]/2;
            }
        }
        for (int i = 0; i < n-1; i++) {
            for (int j = 0; j < k-1; j++) {
                if (i < j) {
                    ans[i][j] = 0;
                }else{
                    ans[i+1][j+1] = (ans[i][j] + ans[i][j+1])/2;
                }
            }
        }
        return ans;
    }
}


Measured memory_bytes: 23764
#include<stdio.h>
int main(){
int a,b,c,i,ans,keep;
scanf("%d%d%d",&a,&b,&c);
for(i=0;i<2;i++){
if(a<b){
keep=a;
a=b;
b=keep;
}
if(b<c){
keep=b;
b=c;
c=keep;
}
}
ans=a-b;
ans+=(b-c)/2;
if((b-c)%2==1)
ans+=2;
printf("%d\n",ans);
return 0;
}

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

public class Main {
  private static int solve(int x) {
    int[] prices = new int[]{
      100,
      101,
      102,
      103,
      104,
      105,
    };
    boolean[] dptable = new boolean[x + 1];
    dptable[0] = true;
    for (int price : prices) {
      for (int j = price; j <= x; j++) {
        dptable[j] |= dptable[j - price];
      }
    }
    return dptable[x] ? 1 : 0;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int x = reader.nextInt();
    out.println(solve(x));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 23124
s = input()

win = 0
lose = 0
for i in range(len(s)):
    if i%2 == 0:
        if s[i] == "g":
            pass
        else:
            lose += 1
    else:
        if s[i] == "g":
            win += 1
        else:
            pass

print(win - lose)    

Measured memory_bytes: 3316
#include <stdio.h>
#define LEN 25000
int Terrain(char* ascii, int len, int p, int q){
  int depth = 0, i;
  double b = 0;
  for(i = p; i < q; i++){
    if(ascii[i] == '/'){
      b += (double)depth - 0.5;
      depth--; }
    if(ascii[i] == '\\'){
      b += (double)depth + 0.5;
      depth++;
    }
    if(ascii[i] == '_'){
      b += depth; }
  }
  return b; }
int main(){
  char ascii[LEN];
  int i, len, det;
  int sum = 0, alt = 0, pl = 0, stk = 0;
  int height[LEN] = {0}, ex[LEN] = {0};
  scanf("%s", ascii);
  for(len = 0; ; len++){
    height[len] = alt;
    if(ascii[len] == '/'){
      alt++; }
    if(ascii[len] == '\\'){
      alt--;
    }
    if(ascii[len] == '\0'){
      break; }
  }
  while(pl < len){
    while(ascii[pl] != '\\' && pl < len){
      pl++; }
    det = pl+1;
    while(det <= len && height[det] != height[pl]){
      det++; }
    if(det <= len){
      ex[stk++] = Terrain(ascii, len, pl, det);
      pl = det;
    }else{ pl++;
    } }
  for(i = 0; i < stk; i++){
    sum += ex[i];
  }
  printf("%d\n%d", sum, stk);

  for(i = 0; i < stk; i++){
    printf(" %d", ex[i]);
  }
  printf("\n");
  return 0; }



Measured memory_bytes: 2104
N = int(input())
S = input().strip()

bcnt = S.count("#")
wcnt = N - bcnt

ans = wcnt
cntb = 0
cntw = 0
for i in range(N):
    if S[i] == "#":
        cntb += 1
    else:
        cntw += 1

    ans = min(ans, cntb + wcnt - cntw)


print(ans)



Measured memory_bytes: 9392
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    for(int i=0;i<k;i++){
        int a,b;
        cin >> a >> b;
        int min=a-1;
        if(min>(n-a)){
            min=n-a;
        }
        if(min>(b-1)){
            min=b-1;
        }
        if(min>(n-b)){
            min=n-b;
        }
        int m=min%3;
        if(m==0){
            cout << "1" << endl;
        }else if(m==1){
            cout << "2" << endl;
        }else{
            cout << "3" << endl;
        }
    }
    
    return 0;
}



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

using namespace std;

int main()
{
	int N;
	string S;
	cin >> N >> S;

	vector<int> E(N, 0), W(N, 0);

	if (S[0] == 'E') {
		E[0] = 1;
	}
	else {
		W[0] = 1;
	}

	for (int i = 1; i < N; ++i) {
		E[i] = E[i - 1];
		W[i] = W[i - 1];
		if (S[i] == 'E') {
			++E[i];
		}
		else {
			++W[i];
		}
	}

	auto countE = [&](int l, int r) {
		if (r < l) {
			return 0;
		}
		int ans = E[r];
		if (l != 0) {
			ans -= E[l - 1];
		}
		return ans;
	};

	auto countW = [&](int l, int r) {
		if (r < l) {
			return 0;
		}
		int ans = W[r];
		if (l != 0) {
			ans -= W[l - 1];
		}
		return ans;
	};

	int ans = N;

	for (int i = 0; i < N; ++i) {
		int ret = countW(0, i - 1) + countE(i + 1, N - 1);
		ans = min(ans, ret);
	}

	cout << ans << endl;
}


Measured memory_bytes: 3076
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

int N, A[1<<20];

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);

 char ch;
 int rem = 0;
 while(ch = getchar()) {
   if(ch == '\n') break;
   rem = rem*10 + (ch-'0');
   rem %= 9;
 }
 if(rem == 0) cout<<"Yes";
 else cout<<"No";


 return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t N,D;
  cin >> N >> D;
  
  vector<int64_t> X(N), Y(N);
  for (int i = 0; i < N; i++) {
    cin >> X.at(i) >> Y.at(i);
  }
  
  int C;
  C = 0;
 
  for (int i = 0; i < N; i++) {
    if ( X.at(i)*X.at(i) + Y.at(i)*Y.at(i) <= D*D ) {
      C = C + 1;
    }
    else {
     
    }
  }
  
  cout << C << endl;
  
}
  

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

using namespace std;

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

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

using Graph = vector<vector<int>>;

void dfs(int v, const Graph &G, vector<int> &res, vector<int> &used)
{
    used[v] = 1;
    for (auto to : G[v])
        if (used[to] == 0)
        {
            dfs(to, G, res, used);
        }
    res.push_back(v);
}

vector<int> topo_sort(const Graph &G)
{
    int V = G.size();
    vector<int> ide(V);
    for (int i = 0; i < V; i++)
    {
        for (auto to : G[i])
        {
            ide[to]++;
        }
    }
    vector<int> res;
    vector<int> used(V);
    for (int i = V - 1; i >= 0; i--)
    {
        if (ide[i] == 0)
        {
            dfs(i, G, res, used);
        }
    }
    if (res.size() == 0)
        res = {-1};
    reverse(res.begin(), res.end());
    return res;
}

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

    int V, E;
    cin >> V >> E;
    Graph g(V);
    while (E--)
    {
        int s, t;
        cin >> s >> t;
        g[s].push_back(t);
    }
    auto ret = topo_sort(g);
    for (int i = 0; i < V; i++)
        cout << ret[i] << endl;
}



Measured memory_bytes: 3808
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <utility>

using namespace std;

int main()
{
    int a, b, c, x, y, ans=0;
    cin>>a>>b>>c>>x>>y;
    if (x<=y)
    {
        if (a+b<=2*c) ans+=a*x+b*y;
        else
        {
            ans+=x*2*c;
            if (b<=2*c) ans+=b*(y-x);
            else ans+=(y-x)*2*c;
        }
    }
    else
    {
        if (a+b<=2*c) ans+=a*x+b*y;
        else
        {
            ans+=y*2*c;
            if (a<=2*c) ans+=a*(x-y);
            else ans+=(x-y)*2*c;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  int N,T,A;
  cin >> N >> T >> A;
  double mi=1e8;
  int ans;
  for(int i=1;i<=N;i++){
    int H;
    cin >> H;
    double diff=abs(T-H*0.006-A);
    if(mi>diff){
      mi=diff;
      ans=i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000000+7
typedef long long int lint;

int main (){
  int N = 0;
  string S,ans = "AC";
  cin >> S;
  
  if(S.at(0) != 'A'){ans = "WA";}
  if(S.at(S.size()-1) == 'C'){ans = "WA";}
  rep(i,2,S.size() - 1){
    if(S[i] == 'C'){N++;}
  }
  if(N != 1){ans = "WA";}
  else{
    rep(i,1,S.size()){
    if(isupper(S[i]) && S[i] != 'C'){ans = "WA";}
    }
  }
  co(ans);
}

Measured memory_bytes: 256
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(n);

  V v(n+1,0);

  auto f = [&](int p){
    int s = p;
    FOR(i,2,p+1){

      if(s%i)continue;

      v[i]++;
      s/=i;

      i--;

    }
  };

  FOR(i, 2, n+1)
    f(i);

  ll ans = 1;
  FOR(i,2,n+1){
    if(v[i]==0)continue;
    ans *= v[i]+1;
    ans%=MOD;
  }
  COUT(ans);

  return 0;
}

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

#s = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
sx=hoge[0]
sy=hoge[1]
tx=hoge[2]
ty=hoge[3]


ans = ""

ans+="L"
for i in range(0,ty-sy+1):
	ans+="U"
for i in range(0,tx-sx+1):
	ans+="R"
ans+="D"

for i in range(0,tx-sx):
	ans+="L"
for i in range(0,ty-sy):
	ans+="D"

for i in range(0,tx-sx):
	ans+="R"
for i in range(0,ty-sy):
	ans+="U"

ans+="R"
for i in range(0,ty-sy+1):
	ans+="D"
for i in range(0,tx-sx+1):
	ans+="L"
ans+="U"

print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#define LEN 4000000
#define NIL -1

int trance_command(char []);
void insert(int);
void print();
void inorder(int);
void preorder(int);

int P[LEN], L[LEN], R[LEN], Key[LEN];
int root=NIL;

int main()
{
  char command[10];
  int n, id;
  int z=0;
  int i, j, k;

  //intelization
  for(i=0; i<LEN; i++)
    {
      P[i]=NIL;
      L[i]=NIL;
      R[i]=NIL;
      Key[i]=NIL;
    }

  //read
  scanf("%d", &n);
  for(i=0; i<n; i++)
    {
      scanf("%s", command);
      //insert
      if(trance_command(command)==0)
	{
	  scanf("%d", &id);
	  Key[z]=id;
	  insert(z);
	  z++;
	}
      //print
      else
	{
	  inorder(root);
	  printf("\n");
	  preorder(root);
	  printf("\n");
	}
    }

  return 0;
}


//-------------------------
//this method is trancing command.
int trance_command(char c[])
{
  if(strcmp(c, "insert")==0)return 0;
  else if(strcmp(c, "print"))return 1;
}

void insert(int z)
{
  int y=NIL;
  int x=root;

  while(x!=NIL)
    {
      y = x;
      if(Key[z]<Key[x])x = L[x];
      else x = R[x];
    }
  P[z]=y;

  if(y==NIL)root=z;
  else if(Key[z]<Key[y])L[y]=z;
  else R[y]=z;
}

void inorder(int t)
{
  if(t!=NIL)
    {
      inorder(L[t]);
      printf(" %d", Key[t]);
      inorder(R[t]);
    }
}

void preorder(int t)
{
  if(t!=NIL)
    {
      printf(" %d", Key[t]);
      preorder(L[t]);
      preorder(R[t]);
    }
}

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

using namespace std;
 
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int W, a, b;
    cin >> W >> a >> b;
    if(a < b){
        int hoge = W+a;
        if(hoge >= b)cout<<0<<endl;
        else cout<<b-hoge<<endl;
    }else{
        int hoge = W+b;
        if(hoge >= a)cout<<0<<endl;
        else cout<<a-hoge<<endl;
    }
}

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

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def lcm(a, b):
    return a*b//gcd(a, b)

N, M = map(int, input().split())
a = list(map(int, input().split()))
b = [ai//2 for ai in a]
cnt = [0]*N

for i in range(N):
    tmp = b[i]
    
    while tmp%2==0:
        tmp //= 2
        cnt[i] += 1

if len(set(cnt))!=1:
    print(0)
    exit()

L = 1

for bi in b:
    L = lcm(L, bi)

L2 = 1

for ai in a:
    L2 = lcm(L2, ai)

if L>M:
    print(0)
else:
    print((M-L)//L2+1)

Measured memory_bytes: 60900
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n;
  cin >>n;
  ll a[n],b[n];
  for(ll i=0;i<n;i++) cin >>a[i];
  ll f=0,t=0,o=0;
  for(ll i=0;i<n;i++){
    ll s=a[i],k=0;
    while(1){
      if(s==0) break;
      if(s%2==0){
        k++;
        s/=2;
      }
      else break;
    }
    if(k>=2) f++;
    else if(k==1) t++;
    else o++;
  }
  if(f==0){
    if(o>=1||t==1) cout <<"No"<<endl;
    else cout <<"Yes"<<endl;
  }
  else{
    if(o==(f+1)){
      if(t==0){
        cout <<"Yes"<<endl;
        return 0;
      }
      else{
        cout <<"No"<<endl;
        return 0;
      }
    }
    else if(o<(f+1)){
      cout <<"Yes"<<endl;
      return 0;
    }
    else {
      cout <<"No"<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
    int a,sum=0;
    cin>>a;
    sum+=a;
    for(int i=2;i<=3;i++)
    {
        sum+=pow(a,i);
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 4036
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int map[14][14];
void dfs(int x,int y)
{
	map[x][y]=0;
	if(map[x-1][y]==0&&map[x][y+1]==0&&map[x+1][y]==0&&map[x][y-1]==0)
	{
		return;
	}
	if(map[x-1][y])
	{
		dfs(x-1,y);
	}
	if(map[x][y+1])
	{
		dfs(x,y+1);
	}
	if(map[x+1][y])
	{
		dfs(x+1,y);
	}
	if(map[x][y-1])
	{
		dfs(x,y-1);
	}
}
int main()
{
	while(1)
	{
	string s;
	for(int i=1;i<=12;i++)
	{
		if(!(cin >> s))goto end;
		for(int j=1;j<=12;j++)
		{
			map[i][j]=(s[j-1]-'0');
		}
	}
	int ans=0;
	int p,q;
	while(1)
	{
		p=q=-1;
		bool up;
		for(int i=1;i<=12;i++)
		{
			for(int j=1;j<=12;j++)
			{
			        up=false;
				if(map[i][j]==1)
				{
					p=i;
					q=j;
					up=true;
					break;
				}
			}
			if(up)break;
		}
		if(p==-1&&q==-1)break;
		dfs(p,q);
		ans++;
	}
	cout << ans << endl;
	}
	end: ;
	return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class Node{
    public:
        Node(int _id, int _x):id(_id),x(_x){}
        int id;
        int x;
        bool operator<(const Node &node) const{
            return x<node.x;
        }
};

long long int walk(int p, const int n, const vector<Node> l, const vector<Node> r, vector<int> color){
    int pl = n-1;
    int pr = 0;
    long long int td = 0;
    for(int i=0;i<n;++i){
        while(pl>=0 && color[l[pl].id]==1){
            --pl;
        }
        while(pr<n && color[r[pr].id]==1){
            ++pr;
        }
        int ld = 0;
        int rd = 0;
        if(pl>=0){
            int x = l[pl].x;
            if(x>=p){
               ld = x-p; 
            }
        }
        if(pr<n){
            int x = r[pr].x;
            if(p>=x)
                rd = p-x;
        }
        if(pl>=0 && ld>=rd){
            p += ld;
            td += ld;
            color[l[pl].id] = 1;
            --pl;
        }
        else if(pr<n){
            p -= rd;
            td += rd;
            color[r[pr].id] = 1;
            ++pr;
        }
        //cout<<p<<" "<<td<<endl;
    }
    td+=abs(p);
    return td;
}
int main(){
    vector<Node> l;
    vector<Node> r;
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        int x,y;
        cin>>x>>y;
        l.push_back(Node(i,x));
        r.push_back(Node(i,y));
    }
    sort(l.begin(),l.end());
    sort(r.begin(),r.end());
    vector<int> color(n);
    
    
    int p = 0;
    if(l[n-1].x>0){
        p = l[n-1].x;
        color[l[n-1].id] = 1;
    }
    long long int td1 = walk(p,n,l,r,color) + p;
    //fill(color.begin(),color.end(),0);
    for(int i=0;i<color.size();++i)
        color[i] = 0;
    p = 0;
    if(r[0].x<0){
        p = r[0].x;
        color[r[0].id] = 1;
    }
    long long int td2 = walk(p,n,l,r,color) - p;
    long long int td = td1>td2?td1:td2;
    cout<<td<<"\n";
}


Measured memory_bytes: 4204
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int tmp;
    int n;  cin>>n;
    vector<int>d(n);
    for(auto i:d){cin>>tmp;d.push_back(tmp);}
    int m;  cin>>m;
    vector<int>t(m);
    for(auto i:t){cin>>tmp;t.push_back(tmp);}
    sort(d.begin(),d.end());
    sort(t.begin(),t.end());
    while(!t.empty()){
        if(d.back()==t.back()){d.pop_back();t.pop_back();}
        else if(d.back()>t.back())d.pop_back();
        else {cout<<"NO"<<endl;return 0;}
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 4208
n = int(input())
a = list(map(int, input().split()))

rates = [0]*9
for i in range(n):
  r = min(a[i]//400, 8)
  rates[r] += 1

n_min, n_max = 0, 0
if max(rates[:-1]) > 0:
  for i in range(8):
    n_min += 1 if rates[i] > 0 else 0
  n_max = n_min+rates[-1]
else:
  n_min = 1
  n_max = rates[-1]

print(n_min, n_max)

Measured memory_bytes: 3188
mod = 10**9+7
n,k = map(int,input().split())
ans = 0
lst1 = [i for i in range(n+2)]
lst2 = lst1[::-1]
s1 = [0]*(n+2)
s2 = [0]*(n+2)
for i in range(1,n+2): 
    s1[i] = (s1[i-1] + lst1[i-1])%mod
    s2[i] = (s2[i-1] + lst2[i])%mod
for i in range(k,n+2):
    ans += (s2[i] - s1[i] + 1)%mod
    ans %= mod
print(ans)

Measured memory_bytes: 34324
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,t;
  cin >> n >> t;
  int a[t];
  for(int i=0;i<t;i++){
    cin >> a[i];
    if(a[i]>n/2+n%2){
      cout << 2*a[i]-n-1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a < 10 && b < 10 ? a * b : -1) << endl;
    return 0;
}


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

int main()
{
  int H, W;
  cin >> H >> W;
  vector<string> svec(H);
  for (int i = 0; i < H; i++)
  {
    cin >> svec[i];
  }
  for (int i = 0; i < H; i++)
  {
    cout << svec[i] << endl;
    cout << svec[i] << endl;
  }
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()

a = [0] * N
for i in range(N-1):
  if S[i:i+2] == 'AC':
    a[i] = 1

cumsum = [0]
for _a in a:
  cumsum.append(cumsum[-1] + _a)


for i in range(Q):
  l, r = map(int, input().split())
  print(cumsum[r-1] - cumsum[l-1])  

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

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let q: usize = iter.next().unwrap().parse().unwrap();
    let s: Vec<char> = iter.next().unwrap().chars().collect();
    let mut a = vec![0; n+1];
    for i in 0..n-1 {
        if s[i] == 'A' && s[i+1] == 'C' {
            a[i+1] = 1;
        }
    }
    for i in 1..n+1 { 
        a[i] += a[i-1];
    }
    for _ in 0..q {
        let l: usize = iter.next().unwrap().parse().unwrap();
        let r: usize = iter.next().unwrap().parse().unwrap();
        println!("{}", a[r-1]-a[l-1]);
    }
}


Measured memory_bytes: 6908
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int W, H;
    static char[][] field;
    static boolean[][] check;
    static String input;
    public static void main(String[] args) {
        while(read()){
            solve();
        }
    }

    static boolean read(){
        if(!sc.hasNext())return false;
        H = sc.nextInt();
        W = sc.nextInt();
        if(W == 0 || H == 0)return false;
        field = new char[H][W];
        check = new boolean[H][W];
        for(int i = 0; i < H; i++){
            field[i] = sc.next().toCharArray();
        }
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                check[i][j] = false;
            }
        }
        return true;
    }

    static void solve(){
        int x = 0, y = 0;
        char vector = 0;
        while(true){

            if(check[y][x] == true){
                System.out.println("LOOP");
                break;
            }
            if(field[y][x] == '.'){
                System.out.print(x + " ");
                System.out.println(y);
                break;
            }
            vector = field[y][x];
            check[y][x] =  true;
            x = x + nextVectorX(vector);
            y = y + nextVectorY(vector);
        }
    }

    static int nextVectorX(char v){
        if(v == '>'){
            return 1;
        }else if(v == '<'){
            return -1;
        }else if(v == '^'){
            return 0;
        }else {
            return 0;
        }
    }

    static int nextVectorY(char v){
        if(v == '>'){
            return 0;
        }else if(v == '<'){
            return 0;
        }else if(v == '^'){
            return -1;
        }else {
            return 1;
        }
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<bool> > even(h, vector<bool>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            int b;
            cin >> b;
            even[i][j] = b%2 == 0;
        }
    }
    vector<int> ys,xs,yt,xt;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(even[i][j]) continue;
            if(j!=w-1){
                ys.push_back(i);
                xs.push_back(j);
                yt.push_back(i);
                xt.push_back(j+1);
                even[i][j+1] = !even[i][j+1];
                continue;
            }
            if(i!=h-1){
                ys.push_back(i);
                xs.push_back(j);
                yt.push_back(i+1);
                xt.push_back(j);
                even[i+1][j] = !even[i+1][j];
            }
        }
    }

    cout << ys.size() << endl;
    for(int i=0; i<(int)ys.size(); i++){
        cout << ys[i]+1 << " " << xs[i]+1 << " " << yt[i]+1 << " " << xt[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4200
using System;

class quiz
{
    public int solve(int[] NABCD)
    {
        int x = 0, y = 0;

        if (NABCD[0] % NABCD[1] == 0)
            x = NABCD[0] / NABCD[1] * NABCD[2];
        else
            x = ((NABCD[0] / NABCD[1]) + 1) * NABCD[2];

        if (NABCD[0] % NABCD[3] == 0)
            y = NABCD[0] / NABCD[3] * NABCD[4];
        else
            y = ((NABCD[0] / NABCD[3]) + 1) * NABCD[4];

        return Math.Min(x, y);
    }

    public int[] ParseIntBySpace(string str)
    {
        int[] array = new int[str.Length];
        int lastloc = 0, spaceloc = -1;

        for (int i = 0; i < str.Length; i++)
        {
            if (str[i] == ' ')
            {
                array[lastloc++] = int.Parse(str.Substring(spaceloc + 1, i - spaceloc - 1));
                spaceloc = i;
            }
            else if (i == str.Length - 1)
            {
                array[lastloc++] = int.Parse(str.Substring(spaceloc + 1, i - spaceloc));
            }
        }

        Array.Resize(ref array, lastloc);

        return array;
    }
}

class Example
{
    static void Main()
    {
        quiz ex = new quiz();

        //while (true)
        //{
        Console.WriteLine(ex.solve(ex.ParseIntBySpace(Console.ReadLine())));
        //}
    }
}


Measured memory_bytes: 19984
from sys import stdin
from decimal import Decimal
def main():
    #入力
    readline=stdin.readline
    a,b,c=map(lambda x:Decimal(x),readline().split())
    
    if a.sqrt()+b.sqrt()<c.sqrt():
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()

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

using namespace std;

int main() {
    int n, d, x;
    cin >> n >> d >> x;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a.at(i);
    int total = n + x;
    for(int i = 0; i < n; ++i) {
        for(int j = 1; j <= 100; j++) {
            int day = j * a.at(i) + 1;
            if (day <= d) ++total;
            else break;
        }
    } 
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
bool cmp(int a,int b)
{
	return a>b;
}
int a[110],b[110];
int main()
{
	int n,m;
	int x,y;
	scanf("%d%d%d%d",&n,&m,&x,&y);
	int mini=0x3f3f3f3f;
	int maxi=-0x3f3f3f3f;
	int t;
	bool sign1=false,sign2=false;
	for(int i=0;i<n;i++){
		scanf("%d",&t);
		if(t>=x&&t<=y){
			maxi=max(maxi,t);
			sign1=true;
		}
	}
	for(int i=0;i<m;i++){
		scanf("%d",&t);
		if(t>=x&&t<=y){
			mini=min(mini,t);
			sign2=true;
		}
	}
	if(maxi<mini&&sign1&&sign2)
		puts("No War");
	else
		puts("War");
		

	return 0;
}

Measured memory_bytes: 256
'use strict';
function main(input) {
    const args = input.split(' ').map((n) => parseInt(n, 10));
	let total = 0
	for(let i = 0;i <= args[0]; i++) {
    	const re = String(i).split('').map(x=> Number(x)).reduce((a, b)=>a+b)
        if(args[1] <= re && re <= args[2]) total = total + i
    }
  	console.log(total)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 14696
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001

int main(void) {
	string s; cin >> s;
	int d = s.size();
	vi v; rep(i,d) v.push_back(s[i]-'0');
	int k; cin >> k;
	vector<vector<vector<int>>> dp(105,vvi(5,vi(2,0)));
	dp[0][0][0] = 1;
	rep(i,d)rep(j,4)rep(r,2){
		for(int x=0; x<=(r?9:v[i]); x++)
			dp[i+1][(x!=0?(j+1):j)][r||x!=v[i]] += dp[i][j][r];
	}
	ll ans = dp[d][k][0] + dp[d][k][1];
	cout << ans << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;

int main(){
    ll N; cin >> N;
    vector<ll> A(N);
    ll sum=0, ans = INF;

    for(int i=0;i<N;++i){
        cin  >> A[i];
        sum += A[i];
    }
    ll snuke = A[0];
    ans = min(ans, abs(snuke - (sum - snuke)));
    for(int i=1;i<N-1;++i){
        snuke += A[i];
        ans = min(ans, abs(snuke - (sum - snuke)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int n;
int ar[N];
int gP[N];
int gS[N];

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

int main(){
    scanf("%d" , &n);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &ar[i]);
        gP[i] = gcd(gP[i - 1] , ar[i]);
    }
    for(int i = n; i >= 1; i--){
        gS[i] = gcd(gS[i + 1] , ar[i]);
    }
    int best = gP[n];
    for(int i = 1; i <= n; i++){
        best = max(1ll*best , gcd(gP[i - 1] , gS[i + 1]));
    }
    printf("%d\n" , best);
}

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
#define EPS 1e-9

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 3005, M = 1e6 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int grid[N][N], n, m, k;

ll dp[N][N][5];

ll solve(int i, int j, int cnt){
    if(i == n)  return 0;
    if(j == m)  return 0;

    ll &ret = dp[i][j][cnt];
    if(~ret)    return ret;


    if(grid[i][j] && cnt < 3){
        ret = max(ret, grid[i][j] + solve(i, j + 1, cnt + 1));
        ret = max(ret, grid[i][j] + solve(i + 1, j, 0));
    }
    ret = max(ret, solve(i, j + 1, cnt));
    ret = max(ret, solve(i + 1, j, 0));

    return ret;
}

int r, c, v;

void go(int tc = 0){
    cin >> n >> m >> k;
    for(int i = 0;i < k;i++){
        cin >> r >> c >> v;
        r--, c--;
        grid[r][c] = v;
    }

    memset(dp, -1, sizeof dp);
    cout << solve(0, 0, 0);

}

int main(){
    init();

//    freopen("in.in", "r", stdin);
//    freopen("out.out", "w", stdout);

   int t = 1, tc = 1;
//   cin >> t;
    while(t--)
        go(tc++);
}

Measured memory_bytes: 392172
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
bool same(vector<int>v) {
	return all_of(v.begin(), v.end(), [&](const int a) {
		return a == v[0]; });

}
int main() {
	int N; cin >> N;
	vector<long double>as;
	for (int i = 0; i < N; ++i) {
		int a; cin >> a;
		as.push_back(a);
	}
	sort(as.begin(), as.end());
	long double ans = 0;
	for (int d = 0; d < N; ++d) {
		for (int c = d+1; c < N; ++c) {
			long double bo = as[c] - as[d];
			long double si;
			swap(c, d);
			if (c == N - 2 && d == N - 1) {
				si = as[N - 3] + as[N - 4];
			}
			else if (c==N-3&&d == N - 1) {
				si = as[N - 2] + as[N - 4];
			}
			else if (c == N - 3 && d == N - 2) {
				si = as[N - 1] + as[N - 4];
			}
			else if (d == N - 1) {
				si = as[N - 2] + as[N - 3];
			}
			else if (d == N - 2) {
				si = as[N - 1] + as[N - 3];
			}
			else {
				si = as[N - 1] + as[N - 2];
			}
			ans = max(ans, si / bo);
			swap(c, d);
		}
	}
	cout <<fixed<<setprecision(10)<< ans << endl;
	return 0;
}

Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=5e5+5;
const int mod=1e9+7;


struct Query{
	int l,r,id;
};

Query Q[N];
int ans[N],a[N],cnt[N];
int cur_res;

void add(int t,int val){
	if(val==1){
		if(++cnt[a[t]]==1) ++cur_res;
	}
	else{
		if(--cnt[a[t]]==0) --cur_res;
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,q;
	cin>>n>>q;
	for(int i=0;i<n;++i) cin>>a[i];
	for(int i=0;i<q;++i){
		int x,y;
		cin>>x>>y;
		--x;
		Q[i]=Query{x,y,i};
	}
	int num=1000;
	auto cmp=[&](const Query& a,const Query& b){
		int al=a.l/num;
		int bl=b.l/num;
		return al<bl||(al==bl&&a.r<b.r);
	};
	sort(Q,Q+q,cmp);
	int l=0,r=0;
	for(int i=0;i<q;++i){
		while(l>Q[i].l) add(--l,1);
		while(l<Q[i].l) add(l++,-1);
		while(r>Q[i].r) add(--r,-1);
		while(r<Q[i].r) add(r++,1);
		ans[Q[i].id]=cur_res;
	} 
	for(int i=0;i<q;++i){
		cout<<ans[i]<<endl;
	}
	return 0;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int H = scan.nextInt();
        int W = scan.nextInt();
        char[][] map = new char[H][W];
        for (int i = 0; i < H; i++) {
            map[i] = scan.next().toCharArray();
        }
        for(int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (map[i][j] == '#') {
                    continue;
                }
                long count = 0;
                for (int k = Math.max(i-1,0); k < Math.min(H, i+2); k++) {
                    for (int l = Math.max(j-1,0); l < Math.min(W, j+2); l++) {
                        if (map[k][l] == '#') {
                            count += 1;
                        }
                    }
                }
                map[i][j] = (char)(count + 48);
            }
        }
        for (int i = 0; i < H; i++) {
            System.out.println(map[i]);
        }
    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int H, W;

char ch[333][333];

int S[777][777], B[333][333];

long long Solve() {
    memset(S, 0, sizeof S);
    for(int XY = 2; XY <= H + W; XY++)
        for(int X = max(XY - W, 1); X <= min(H, XY - 1); X++)
            S[XY][X] = S[XY][X - 1] + B[X][XY - X];
    long long ans = 0;
    for(int X2 = 1; X2 <= H; X2++)
        for(int Y2 = 1; Y2 <= W; Y2++) if(B[X2][Y2])
            for(int a = 1; X2 - a > 0 && Y2 + a <= W && X2 + Y2 + 2 * a <= H + W; a++) if(B[X2 - a][Y2 + a]) {
                int s = X2 + Y2 + 2 * a;
                int l = max(s - W, 1), r = min(H, s - 1);
                l = max(l, X2 + 1);
                r = min(r, a + X2 - 1);
                ans += S[s][r] - S[s][l - 1];
            }
    return ans;
}

long long check() {
    long long ans = 0;
    for(int i = 1; i <= W; i++)
        for(int l = 1; l <= H; l++) if(B[l][i])
            for(int r = l + 2; r <= H; r += 2) if(B[r][i]) {
                int t = (r - l) / 2;
                if(i - t > 0) ans += B[l + t][i - t];
                if(i + t <= W) ans += B[l + t][i + t];
            }
    for(int i = 1; i <= H; i++)
        for(int l = 1; l <= W; l++) if(B[i][l])
            for(int r = l + 2; r <= W; r += 2) if(B[i][r]) {
                int t = (r - l) / 2;
                if(i - t > 0) ans += B[i - t][l + t];
                if(i + t <= H) ans += B[i + t][l + t];
            }
    return ans;
}

int main() {
    scanf("%d%d", &H, &W);
    for(int i = 1; i <= H; i++) {
        scanf("%s", ch[i] + 1);
        for(int j = 1; j <= W; j++)
            B[j][i] = ch[i][j] == '#';
    }
    swap(H, W);
    long long ans = check();
    ans += Solve();
    for(int i = 1; i <= H; i++)
        for(int j = 1, k = W; j < k; j++, k--)
            swap(B[i][j], B[i][k]);
    ans += Solve();
    for(int i = 1, j = H; i < j; i++, j--)
        for(int k = 1; k <= W; k++)
            swap(B[i][k], B[j][k]);
    ans += Solve();
    for(int i = 1; i <= H; i++)
        for(int j = 1, k = W; j < k; j++, k--)
            swap(B[i][j], B[i][k]);
    ans += Solve();
    printf("%lld\n", ans);
    return 0;
}

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

int main() {
	
	int N, M;
	vector< vector<int> > a_N, a_M;
	int i,j,x,y;
	bool ans = false;
	
	cin >> N;
	cin >> M;
	
	a_N.resize(N);
	for ( i = 0; i < N; i++ ) {
		a_N[i].resize(N);
	}
	
	a_M.resize(M);
	for ( i = 0; i < M; i++ ) {
		a_M[i].resize(M);
	}
	
	for (  i = 0; i < N; i++ ) {
		string s;
		cin >> s;
		
		for ( j = 0; j < N; j++ ) {
			a_N[i][j] = ( s.substr(j,1) == "#" ) ? 1 : 0;
		}
	}
	for (  i = 0; i < M; i++ ) {		
		string s;
		cin >> s;
		
		for ( j = 0; j < M; j++ ) {
			a_M[i][j] = ( s.substr(j,1) == "#" ) ? 1 : 0;
		}
	}
	
	for (  i = 0; i <= N-M; i++ ) {
	for (  j = 0; j <= N-M; j++ ) {
		
		bool match = true;
		
		for (  x = 0; x < M; x++ ) {
		for (  y = 0; y < M; y++ ) {
			
			if ( a_M[x][y] != a_N[i+x][j+y] ) { match = false; }
			
		}
		}
		if ( match ) {
			ans = true;
		}
	}
	}
	
	cout << ( ans ? "Yes" : "No" ) << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int dis[1010][1010];

int main(){
  queue<pint> que;
  int h,w;
  cin >> h >> w;
  rep(i,h){
    rep(j,w)dis[i][j]=inf;
  }
  char c[h][w];
  rep(i,h){
    rep(j,w){
      cin >> c[i][j];
      if(c[i][j]=='#'){
        que.push({i,j});
        dis[i][j]=0;
      }
    }
  }
  int ans=0;
  int d[5]={0,-1,0,1,0};
  while(!que.empty()){
    queue<pint> temp;
    int cnt=0;
    while(!que.empty()){
      pint p=que.front();
      que.pop();
      c[p.first][p.second]='#';
      rep(i,4){
        int nx=p.first+d[i],ny=p.second+d[i+1];
        if(0<=nx && nx<h && 0<=ny && ny<w && c[nx][ny]=='.' && dis[nx][ny]==inf){
          temp.push({nx,ny});
          dis[nx][ny]=0;
          cnt++;
        }
      }
    }
    if(cnt!=0)ans++;
    que.swap(temp);
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 13328
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
	Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int M = s.nextInt();
		int[] c = new int[M];
		for(int i = 0; i < M; i++) {
			c[i] = s.nextInt();
		}
		
		int[] dp = new int[N+1];
		for(int i = 0; i < N + 1; i++) {
			dp[i] = 1000000;
		}
		dp[0] = 0;
		
		for(int i = 0; i < M; i++) {
			for(int j = c[i]; j < N + 1; j++ ) {
				dp[j] = Math.min(dp[j], dp[j-c[i]] + 1);
			}
		}
		
		System.out.println(dp[N]);	
    }
}


Measured memory_bytes: 26980
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
    n = int(input().strip())
    s = input().strip()
    dp = [[0] * (n+1) for _ in range(n+1)]
    # dp[n-1][n-1] = 1
    ans = 0
    for i in reversed(range(n)):
        for j in reversed(range(n)):
            if s[i] == s[j]:
                dp[i][j] = min(abs(j - i), dp[i+1][j+1] + 1)
            ans = max(ans, dp[i][j])
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 231816
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[100005];
ll dp[100005];
ll n;
ll solve(ll k){
	if(dp[k])
		return dp[k];
	for(int i=0;i<n;i++){
		if(k>=a[i]){
			if(solve(k-a[i])==2){
				dp[k]=1;
				return dp[k];
			}
			
		}
	}
	dp[k]=2;
	return dp[k];
}
int main(){
	ll k;
	cin>>n>>k;
	
	for(int i=0;i<n; i++){
		cin>>a[i];
	}
	memset(dp,0,sizeof(dp));
	dp[0]=2;
	(solve(k)==2)?cout<<"Second":cout<<"First";
	cout<<endl;
	
	
	return 0;
	
}

Measured memory_bytes: 4096
def main():
    A, B, C, D = map(int, input().split())
    if C <= D: p = gcd(C, D)
    else: p = gcd(D, C)
    lcm = C * D // p
    dA = (A-1) - (A-1) // C - (A-1) // D + (A-1) // lcm
    dB = B - B // C - B // D + B // lcm
    return dB - dA

def gcd(a, b):
    if a == 0: return b
    return gcd(b % a, a)

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main ()
{
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b && a==5 && c==7)
  {
      cout<<"YES";
  }
  else if(a==c && a==5 && b==7)
  {
      cout<<"YES";
  }
  else if(b==c &&b==5 && a==7)
  {
      cout<<"YES";
  }
  else
  {
      cout<<"NO";
  }

    }


Measured memory_bytes: 256