akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main(){
    ll n;
    cin >> n;
    ll a[n];
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0){
            cout << "DENIED";
            return 0;
        }
    }
    cout << "APPROVED";
    return 0;
}


Measured memory_bytes: 3568
/*
	Since
		y ^ x = y % x > x,
	MSB of y and x must be the same.
	Then, y - x < x, and thus
		y % x = y - x,
	which means (y & x) = x.
	Hence, the answer equals to the number of pairs (x, y) such that
		L <= x <= y <= R,
		(MSB of x) = (MSB of y),
		for all i, [i-th bit of x is 1 => that of y is also 1].
*/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)
#define dbg(S) { int f=1; for(auto x:S) cerr<<(f?"[":", ")<<x, f=0; cerr<<"]\n"; }

using namespace std;
using lint=long long;

class mint{
	static const int MOD=1e9+7; // 998244353;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint &operator+=(const mint &m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint &operator-=(const mint &m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint &operator*=(const mint &m){ x=1LL*x*m.x%MOD; return *this; }
	mint &operator/=(const mint &m){ return *this*=m.inverse(); }
	mint operator+(const mint &m)const{ return mint(*this)+=m; }
	mint operator-(const mint &m)const{ return mint(*this)-=m; }
	mint operator*(const mint &m)const{ return mint(*this)*=m; }
	mint operator/(const mint &m)const{ return mint(*this)/=m; }

	mint inverse()const{
		int a=x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend ostream &operator<<(ostream &os,const mint &m){ return os<<m.x; }
	int to_int()const{ return x; }
};

lint L,R;
bool vis[61][2][2][2];
mint memo[61][2][2][2];

mint dfs(int i,bool largerL,bool smallerR,bool msb){
	if(i==-1) return msb?1:0;

	if(vis[i][largerL][smallerR][msb]) return memo[i][largerL][smallerR][msb];
	vis[i][largerL][smallerR][msb]=true;

	mint res=0;
	if(!msb){
		if(L<(1LL<<(i+1)) && (1LL<<i)<=R){
			res+=dfs(i-1,L<(1LL<<i),(1LL<<(i+1))<=R,true); // put 1, 1
		}
		res+=dfs(i-1,false,false,false); // put 0, 0
	}
	else{
		int cnt=0;
		if(largerL || (L>>i&1)==0){
			res+=dfs(i-1,largerL,smallerR||(R>>i&1)==1,true); // put 0, 0
			cnt++;
		}
		if(smallerR || (R>>i&1)==1){
			res+=dfs(i-1,largerL||(L>>i&1)==0,smallerR,true); // put 1, 1
			cnt++;
		}
		if(cnt==2){
			res+=dfs(i-1,largerL,smallerR,true); // put 0, 1
		}
	}
	return memo[i][largerL][smallerR][msb]=res;
}

int main(){
	cin>>L>>R;
	cout<<dfs(60,false,false,false)<<endl;
	return 0;
}


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

int main() {
  int n; cin >> n;
  vector<pair<pair<string,int>, int>> data(n);
  for(int i=0; i<n; i++) {
    string city;
    int point;
    cin >> city >> point;
    data[i] = { {city, -point}, i+1};
  }
  
  sort(data.begin(), data.end());
  
  for(int i=0; i<n; i++) cout << data[i].second << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc103/tasks/abc103_d

int main() {
    int N, M; cin >> N >> M;
    vector<P> ab;
    REP(i, M) {
        int a, b; cin >> a >> b;
        ab.push_back({b,a});
    }

    sort(ab.begin(), ab.end());

    int ans = 0;
    int now = 0;
    for (P p : ab) {
        int l = p.second;
        int r = p.first;
        if (l >= now) {
            ans++;
            now = r;
        }
    }

    cout << ans << "\n";

    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  char maze[H][W];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> maze[i][j];
    }
  }
  
  int L[H][W];
  int R[H][W];
  int U[H][W];
  int D[H][W];
  
  for (int i = 0; i < H; i++) {
    L[i][0] = 0;
  }
  for (int i = 0; i < H; i++) {
    for (int j = 1; j < W; j++) {
      if (maze[i][j] == '#' || maze[i][j-1] == '#') {
        L[i][j] = 0;
      } else {
        L[i][j] = L[i][j-1] + 1;
      }
    }
  }
  
  for (int j = 0; j < W; j++) {
    U[0][j] = 0;
  }
  for (int i = 1; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (maze[i][j] == '#' || maze[i-1][j] == '#') {
        U[i][j] = 0;
      } else {
        U[i][j] = U[i-1][j] + 1;
      }
    }
  }
  
  for (int i = H-1; i >= 0; i--) {
    R[i][W-1] = 0;
  }
  for (int i = H-1; i >= 0; i--) {
    for (int j = W-2; j >= 0; j--) {
      if (maze[i][j] == '#' || maze[i][j+1] == '#') {
        R[i][j] = 0;
      } else {
        R[i][j] = R[i][j+1] + 1;
      }
    }
  }
  
  for (int j = W-1; j >= 0; j--) {
    D[H-1][j] = 0;
  }
  for (int i = H-2; i >= 0; i--) {
    for (int j = W-1; j >= 0; j--) {
      if (maze[i][j] == '#' || maze[i+1][j] == '#') {
        D[i][j] = 0;
      } else {
        D[i][j] = D[i+1][j] + 1;
      }
    }
  }
  
  int lamp[H][W];
  int ans = 0;
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (maze[i][j] != '#') {
        lamp[i][j] = L[i][j] + U[i][j] + R[i][j] + D[i][j] + 1;
        ans = max(ans, lamp[i][j]);
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 82304
#include<cstdio>
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

int main(void) {
	int N;
	scanf("%d", &N);
	int P[200100];
	int PMin = 200100;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &P[i]);
		// cout << PMin << " " << P[i] << endl;
		if (P[i] <= PMin) ans++;
		PMin = min(PMin, P[i]);
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 4616
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <numeric>

int main()
{
  long long n;
  scanf("%lld", &n);
  long long a[200000];
  for (long long i = 0; i < n; ++i)
  {
    scanf("%lld", a + i);
    a[i] -= (i + 1);
  }
  std::sort(a, a + n);
  long long b = a[n / 2];
  long long ans = 0;
  for (int i = 0; i < n; ++i)
  {
    ans += std::abs(a[i] - b);
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    string s;
    cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7')cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 3572
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll ans = n*n*n;
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] bingo = new int[3][3];
        for(int i = 0; i < 3; i++) {
            for(int j = 0; j < 3; j++) {
                bingo[i][j] = sc.nextInt();
            }
        }
        
        int N = sc.nextInt();
        
        for(int k = 0; k < N; k++) {
            int b = sc.nextInt();
            for(int i = 0; i < 3; i++) {
                for(int j = 0; j < 3; j++) {
                    if(bingo[i][j] == b) {
                        bingo[i][j] = 0;
                    }
                }
            }
        }
        
        boolean ans = false;
        
        for(int i = 0; i < 3; i++) {
            if(bingo[0][i] == 0 && bingo[1][i] == 0 && bingo[2][i] == 0) {
                ans = true;
            }
            if(bingo[i][0] == 0 && bingo[i][1] == 0 && bingo[i][2] == 0) {
                ans = true;
            }
        }
        
        if(bingo[0][0] == 0 && bingo[1][1] == 0 && bingo[2][2] == 0 || bingo[0][2] == 0 && bingo[1][1] == 0 && bingo[2][0] == 0) {
            ans = true;
        }
            
        if(ans) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
        
        
    }
}

Measured memory_bytes: 22612
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, M = in.next().toInt
  val graph = Array.fill[List[Int]](N+1)(Nil)
  for(_ <- 1 to M) {
    val a, b = in.next().toInt
    graph(a) = b :: graph(a)
  }


  //
  val dp = Array.fill[Int](N+1)(-1)
  val stack = new scala.collection.mutable.Stack[Int]

  def calc(): Unit = {
    while(!stack.isEmpty) {
      val now = stack.pop()

      if(dp(Math.abs(now)) == -1){
        if(now < 0) {
          var res = 0
          for(e <- graph(-now)){
            res = Math.max(res, dp(e)+1)
          }
          dp(-now) = res
        }
        else {
          stack.push(-now)
          for(e <- graph(now)){
            if(dp(e) == -1) {
              stack.push(e)
            }
          }
        }
      }
    }
  }
  
  for (i <- 1 to N) {
    if(dp(i) == -1){
      stack.push(i)
      calc()
    }
  }


  println(dp.max)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 55684
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

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

    ll ans = 0,eq = 0;
    
    FOR(i,1,n-1){
        ll x = i,y = n-i;
        if(x == y) eq++;
        else ans++;
    }

    ans = ans/2;
    cout<<ans<<endl;
}

signed main(){

   FastRead;    
 

    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 256
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Author: z0marlin
Title: d.cpp
Time: 15-08-2019T14:28:26+0530 
I suck at CP T_T
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
#include <bits/stdc++.h>
#if DEBUG
#define dprintf(...) printf(__VA_ARGS__)
#else
#define dprintf(...)
#endif
#define FOR(i, a, n) for(int i = a; i < n; ++i)
#define FORE(a, v) for(auto a:v)
#define MAX(a, b) ((a>b)?a:b)
#define MIN(a, b) ((a<b)?a:b)
#define MP(i, j) make_pair(i, j)
#define PB(a) push_back(a)
#define PPB(a) pop_back(a)
#define all(a) a.begin(), a.end()

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii_t;
typedef pair<ll,ll> pll_t;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;

const int MAX_SZ=1e5+5;
const int MOD=1e9+7;
int t = 1, n, m, q, ql, qr;
char ch;
string s;
vi_t pw10;
ll  dp[MAX_SZ][13];
void buildPow(){
    pw10.resize(MAX_SZ, 1);
    FOR(i,1,MAX_SZ){
        pw10[i] = (pw10[i-1]*10)%13;
    }
}

ll buildDP(int idx, int rem){
    dprintf("{idx: %d, rem: %d}%c\n", idx,rem, (idx>=n)?'*':' ');
    if(idx>=n){
        if(rem==5) {
            return 1LL;
        }
        else{
            return 0LL;
        }
    }
    if(dp[idx][rem] !=-1) return dp[idx][rem];
    int digit;
    ll cnt=0;
    if(s[idx]!='?'){
        digit=s[idx]-'0';
        dp[idx][rem] = buildDP(idx+1, (rem+(digit*pw10[n-idx-1])%13)%13);
        return dp[idx][rem];
    }
    else{
        FOR(dig,0,10){
            cnt = (cnt+buildDP(idx+1, (rem+dig*pw10[n-idx-1])%13))%MOD;
        }
    }
    dp[idx][rem]=cnt;
    return cnt;
}

ll solve(){
    memset(dp, -1, sizeof(dp));
    n=s.length();
    buildPow();
    ll c = buildDP(0, 0);
    return c;
}

int main(){
    // scanf("%d", &t);
    while(t--){
        cin>>s;
        printf("%lld\n", solve());
    }
}

Measured memory_bytes: 17280
#include <bits/stdc++.h>
using namespace std;
int main(){
    char a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    if(a[0]=='a' && a[1]=='b' && a[2]=='c'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const double EPS = 1e-8;
const int MOD = 1000 * 1000 * 1000 + 7;

const int MAX = 5 * 100 * 1000 + 47;

int C[MAX];
int U[MAX];
int CNT[2];
VI G[MAX];

bool DFS(int v, int c)
{
    C[v] = c;
    U[v] = 1;
    CNT[c]++;
    bool bip = 1;
    FOR(i, 0, SZ(G[v]))
    {
        int to = G[v][i];
        if (U[to])
        {
            if (C[to] != c ^ 1)
                bip = 0;
            continue;
        }
        if (!DFS(to, c ^ 1))
            bip = 0;
    }
    return bip;
}


int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    FOR(i, 0, m)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        --a, --b;
        G[a].PB(b);
        G[b].PB(a);
    }
    LL ans = - m;
    FOR(i, 0, n)
        if (!U[i])
        {
            if(DFS(i, 0))
                ans += CNT[0] * 1LL * CNT[1];
            else
                ans += (CNT[0] + CNT[1]) * 1LL * (CNT[0] + CNT[1] - 1) / 2;
        }
    cout << ans << endl;
    
}


Measured memory_bytes: 19328
import math
n=int(input())
def f(x,y):
  return math.atan2(y,x)
  
XY=[]
for i in range(n):
  x,y=map(int,input().split())
  XY.append((x,y,f(x,y)))
XY.sort(key=lambda x:x[2])

def dis(x,y):
  return (x**2+y**2)**0.5
ans=0
for i in range(n):
  for j in range(1,n+1):
    x,y=0,0
    if i+j<=n:
      for k in range(i,i+j):
        x+=XY[k][0]
        y+=XY[k][1]
      ans=max(ans,dis(x,y))
    else:
      for k in range(i,n):
        x+=XY[k][0]
        y+=XY[k][1]
      for k in range(j-(n-i)):
        x+=XY[k][0]
        y+=XY[k][1]
      ans=max(ans,dis(x,y))
print(ans)



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

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

  rep(i, 30) {
    rep(j, 30) {
       if (i*4 + j*7 == N) {
        cout << "Yes" << endl;
        return 0;
       }
    }
  }
  
  cout << "No" << endl;
}


Measured memory_bytes: 256
p=int(input())
A=tuple(map(int,input().split()))

Fact=[1] #階乗
for i in range(1,p):
    Fact.append(Fact[i-1]*i%p)
Finv=[0]*p #階乗の逆元
Finv[-1]=pow(Fact[-1],p-2,p)
for i in range(p-2,-1,-1):
    Finv[i]=Finv[i+1]*(i+1)%p
def comb(n,r):
    if n<r:
        return 0
    return Fact[n]*Finv[r]*Finv[n-r]%p

B=[0]*p
B[0]=sum(A)
for i,a in enumerate(A):
    if a:
        k=1
        for j in reversed(range(p)):
            B[j]+=-comb(p-1,j)*k
            B[j]%=p
            k*=-i
            k%=p
print(*B)

Measured memory_bytes: 44716
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		int m = in.nextInt();
		
		char[][] a = new char[n][n];
		char[][] b = new char[m][m];
		
		for (int i = 0; i < n; i++) {
			a[i] = in.next().toCharArray();
		}
		for (int i = 0; i < m; i++) {
			b[i] = in.next().toCharArray();
		}
		
		boolean isFound = false;
		
		for (int i = 0; i <= n - m && !isFound; i++) {
			for (int j = 0; j <= n - m && !isFound; j++) {
				boolean shouldContinue = true;
				for (int x = 0; x < m && shouldContinue; x++) {
					for (int y = 0; y < m && shouldContinue; y++) {
						shouldContinue = a[i + x][j + y] == b[x][y];
					}
				}
				if (shouldContinue) {
					isFound = true;
				}
			}
		}
		
		System.out.println(isFound ? "Yes" : "No");
	}
}

Measured memory_bytes: 20948
import math
import bisect

# 0以上整数x「未満」の素数をリストに格納して返す
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 

    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]

def is_prime(x):
    if x < 2: return False
    if x == 2 or x == 3 or x == 5: return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False

    
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True


if __name__ == '__main__':
    target = int(input())
    ps = primes(2 * 10**5)
    ans_idx = bisect.bisect_left(ps, target)
    print(ps[ans_idx])



Measured memory_bytes: 11184
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int maxN = 3e5 + 10;
const int maxM = 1e5 + 10;
int fenw[maxM];
void add(int v, int by) {
    while (v < maxM) {
        fenw[v] += by;
        v = (v | (v - 1)) + 1;
    }
}
int get(int r) {
    int ans = 0;
    while (r > 0) {
        ans += fenw[r];
        r &= (r - 1);
    }
    return ans;
}
int get(int l, int r) {
    return get(r) - get(l - 1);
}
int n;
int m;
int l[maxN], r[maxN];
const int INF = (int)1e9;
int ans[maxM];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> m;
    vector < pair < pair < int, int >, int > > events;
    for (int i = 1; i <= n; i++) {
        cin >> l[i] >> r[i];
        events.emplace_back(make_pair(r[i], -INF), l[i]);
    }
    for (int i = 1; i <= m; i++) {
        for (int j = i; j <= m; j += i) {
            int nxt = min(j + i, m + 1);
            events.emplace_back(make_pair(nxt - 1, i), j);
            if (j > 1) events.emplace_back(make_pair(j - 1, ~i), j);
        }
    }
    sort(events.begin(), events.end());
    for (auto it : events) {
        if (it.first.second == -INF) {
            add(it.second, +1);
        }
        else {
            int coef = 1;
            int qu = 1;
            if (it.first.second < 0) {
                coef = -1;
                qu = ~it.first.second;
            }
            else {
                coef = 1;
                qu = it.first.second;
            }
            ans[qu] += coef * get(it.second);
        }
    }
    for (int i = 1; i <= m; i++) cout << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 53988
n = int(input())
h = [int(i) for i in input().split()]
dp = [10**100]*n
dp[0] = 0
for i in range(n):
    for j in [1,2]:
        k = i + j
        # print(i,j,k)
        if k < n:
            # print(dp[k],'before')
            dp[k] = min(dp[k],dp[i]+abs(h[i]-h[k]))
            # print(dp[k],'after')
print(dp[n-1])


Measured memory_bytes: 13928
import math

N, M = map(int, input().split())
S = input()
T = input()

GCD = math.gcd(N, M)
a, b = N//GCD, M//GCD
ans = True
for i in range(GCD):
    if S[i*a] != T[i*b]:
        ans = False
        break

if ans:
    print(a*b*GCD)
else:
    print(-1)

Measured memory_bytes: 9272
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

a, b = ISI()
c = b - a
height = 0
for i in range(1, c):
    height += i
print(height - a)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int a, b, c, d;
  cin >>  a >> b >> c >> d;

  bool ok = false;
  if(abs(a-c) <= d) ok = true;
  if(abs(a-b) <= d && abs(b-c)<= d) ok = true;

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S,T;
    cin >> S >> T;
    int cnt = 0;
    rep(i,0,3)cnt += S[i] == T[i];
    cout << cnt << endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1<<24);

main(){
  int N, P[MAX], dp[2][MAX/2+1][2]; 
  cin >> N;
  for ( int i = 0; i < N-1; i++ ) cin >> P[i];

  for ( int i = 0; i < 2; i++ ){
    for ( int j = 0; j <= N/2; j++ ){
      dp[i][j][0] = dp[i][j][1] = INFTY;
    }
  }
  dp[1][1][1] = 0;
  dp[1][0][0] = 0;

  for ( int i = 1; i < N; i++ ){
    for ( int j = 0; j <= N/2; j++ ){
      dp[(i+1)%2][j][0] = INFTY;
      dp[(i+1)%2][j+1][1] = INFTY;
      // + 0
      dp[(i+1)%2][j][0] = min(dp[(i+1)%2][j][0], dp[i%2][j][0]);
      dp[(i+1)%2][j][0] = min(dp[(i+1)%2][j][0], dp[i%2][j][1] + P[i-1]);
      // + 1
      if ( j+1 > N/2 ) continue;
      dp[(i+1)%2][j+1][1] = min(dp[(i+1)%2][j+1][1], dp[i%2][j][0] + P[i-1]);
      dp[(i+1)%2][j+1][1] = min(dp[(i+1)%2][j+1][1], dp[i%2][j][1]);
    }
  }
  cout << min(dp[0][N/2][0], dp[0][N/2][1]) << endl;
}

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

int main() {
  long long N,K;
  cin >> N >> K;
  vector<long long> T(N);
  for(long long i=0;i<N;i++){
    cin >> T.at(i);
  }
  
  for(long long i=0;i<N-K;i++){
    if(T.at(i) < T.at(i+K)){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  
  
      
}


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

int main(){
    int n;
    int A[1000];
    int y, minj;
    int count = 0;
    cin >> n;
    
    for(int i = 0; i < n; i++){
        cin >> A[i];
        //cout << A[i];
    }
    for(int i = 0; i < n - 1; i++){
        minj = i;
        for(int j = i; j < n; j++){
            
            if(A[j] < A[minj]){
                minj = j;
                
            
            } 
            
        }
        //cout << minj << endl;
        if(i != minj){
            y = A[i];
            A[i] = A[minj];
            A[minj] = y;
            count += 1;
        }
        //A[i] = A[j + 1];
        //A[j + 1] = y;
        
        
    }
    
    for(int i = 0; i < n; i++){
        //cin >> A[i];
        if(i != 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;
    
    
    return 0;
}



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

#define ll long long
#define ld long long

int main() {
    int N, M; cin >> N >> M;
    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H.at(i);
    }
    vector<pair<int, int>> A(M);
    vector<bool> J(N); //灯台を比較して、低い方になったときにtrueを格納する
    for (int i = 0; i < M; i++) {
        cin >> A.at(i).first >> A.at(i).second;
        if (H.at(A.at(i).first - 1) < H.at(A.at(i).second - 1)) {
            J.at(A.at(i).first - 1) = true;
        }
        else if (H.at(A.at(i).first - 1) == H.at(A.at(i).second - 1)) {
            J.at(A.at(i).first - 1) = true;
            J.at(A.at(i).second - 1) = true;
        }
        else {
            J.at(A.at(i).second - 1) = true;
        }
    }
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (J.at(i) == false) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 4568
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools

mod = int(1e9+7)

def main():
    n = int(input())
    a = list(map(int,input().split()))
    a.sort()
    for i in range(1,n):
        if a[i] == a[i-1]:
            print('NO')
            return
    print('YES')
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 87380
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main() {
	
	string sa, sb, sc;
	cin >> sa >> sb >> sc;

	int pa = 0, pb = 0, pc = 0;
	int p = 1;

	while (pa <= sa.length() && pb <= sb.length() && pc <= sc.length()) {
		
		if (p==1) {
			
			if (sa[pa] == 'a') {
				
				p = 1;
			}
			else if (sa[pa] == 'b') {
				
				p = 2;
			}
			else if (sa[pa] == 'c') {
				
				p = 3;
			}
			pa++;
		}
		else if (p == 2) {
			if (sb[pb] == 'a') {
				
				p = 1;
			}
			else if (sb[pb] == 'b') {
				
				p = 2;
			}
			else if (sb[pb] == 'c') {
			
				p = 3;
			}
			pb++;
		}
		else if (p == 3) {
			if (sc[pc] == 'a') {

				p = 1;
			}
			else if (sc[pc] == 'b') {

				p = 2;
			}
			else if (sc[pc] == 'c') {

				p = 3;
			}
			pc++;
		}
	}

	if (p == 1) {
		cout << "A" << endl;
	}
	if (p == 2) {
		cout << "B" << endl;
	}
	if (p == 3) {
		cout << "C" << endl;
	}
	
	




	return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;

char mat[3001][3001];
int bot[3001][3001] = {}, rig[3001][3001] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h, w;
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> mat[i][j];
        }
    }
    for(int i = h-1; i >= 0; i--){
        for(int j = 0; j < w; j++){
            bot[i][j] = bot[i+1][j]+(mat[i][j]=='I');
        }
    }
    for(int j = w-1; j >= 0; j--){
        for(int i = 0; i < h; i++){
            rig[i][j] = rig[i][j+1]+(mat[i][j]=='O');
        }
    }
    ll ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(mat[i][j]=='J')  ans += bot[i][j]*rig[i][j];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 82280
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;

  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

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

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

  ll n;
  std::cin>>n;
  std::string s,t;
  std::cin>>s>>t;

  rep(i,0,n){
    std::cout<<s[i]<<t[i];
  }

  std::cout<<"\n";

  return 0;
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int N;
  ci(N);
  ve<int> A(N);
  rep(i, N){
    ci(A.at(i));
  }
  int a = 0;
  rep(i, N){
    rep(j, N){
      if(i != j){
        a = max(a, abs(A.at(i) - A.at(j)));
      }
    }
  }
  co(a);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define len(x) int(x.size())
#define all(x) x.begin(), x.end()
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> vs(n);
    int sum = 0;
    for(auto &x:vs)
        cin >> x, sum+=x;
    int sum2 = 0;
    int ans = abs(sum-sum2);
    int i = 0;
    int k = 0;
    for(auto x:vs){
        sum2+=x;
        sum-=x;
        ans = min(ans, abs(sum-sum2));
    }
    cout <<ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
using namespace std;
int N; 
int X[100010]; int Y[100010]; bool seen[100010]; 
vector<int> A[100010]; vector<int> B[100010]; vector<int> P[100010]; 
void dfs(int i, int &index){
	if(seen[i]) return; 
	P[index].push_back(i); 
	seen[i] = true; 
	bool finished = true; 
	for(int j = 0; j < A[X[i]].size(); j++){
		if(!seen[A[X[i]].at(j)]) {finished = false; break;} 
	}
	for(int j = 0; j < B[Y[i]].size(); j++){
		if(!seen[B[Y[i]].at(j)]) {finished = false; break; }
	}
	if(finished) return; 
	for(int j = 0; j < A[X[i]].size(); j++){
		dfs(A[X[i]].at(j), index); 
	}
	for(int j = 0; j < B[Y[i]].size(); j++){
		dfs(B[Y[i]].at(j), index); 
	}
}
int main(){
	cin >> N; 
	for(int i = 0; i < N; i++){
		cin >> X[i] >> Y[i]; 
		A[X[i]].push_back(i); B[Y[i]].push_back(i); 
	}
	int index = 0; 
	for(int i = 0; i < N; i++){
		if(seen[i]) continue; 
		dfs(i, index); 
		index ++; 
	}
	long long int ans = 0; 
	for(int i = 0; i <= index; i++){
		set<int> x, y; 
		for(int j = 0; j < P[i].size(); j++){
			x.insert(X[P[i].at(j)]); 
			y.insert(Y[P[i].at(j)]); 
		}
		long long int tmp = (long long) x.size() * y.size(); 
		ans += tmp; 
	}
	cout << ans - (long long) N << endl; 	
}

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

const int mn=1e5+7;

int main()
{
	int d[mn],n,cnt=0,mx=0;
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {scanf("%d",d+i);mx=max(d[i],mx);}
	sort(d+1,d+n+1);
	if(n%2!=0) {puts("0");return 0;}
	for(int i=1;i<=mx;++i) {
		if(lower_bound(d+1,d+n+1,i)-d-1==n/2) cnt++;
	}
	cout<<cnt;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define ui unsigned int 
using namespace std;

int main() {
	int x, y;
	while (cin >> x >> y) {
		if (x == 0 && y == 0) { break; }
		else if (x < y) {
			cout << x << " " << y << endl;
		}
		else
			cout << y << " " << x << endl;
	}
}



Measured memory_bytes: 3100
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let h: usize = itr.next().unwrap().parse().unwrap();
    let w: usize = itr.next().unwrap().parse().unwrap();
    let g: Vec<Vec<char>> = (0..h)
        .map(|_| itr.next().unwrap().chars().collect())
        .collect();
    let dx: Vec<isize> = [0, -1, 0, 1].to_vec();
    let dy: Vec<isize> = [1, 0, -1, 0].to_vec();

    let mut used = vec![vec![false; w]; h];
    let mut q = std::collections::VecDeque::new();
    let mut ans = 0i64;
    for i in 0..h {
        for j in 0..w {
            if !used[i][j] {
                q.push_back((i, j));

                let mut white = 0;
                let mut black = 0;
                while let Some((y, x)) = q.pop_front() {
                    if used[y][x] {
                        continue;
                    }
                    used[y][x] = true;
                    if g[y][x] == '.' {
                        white += 1;
                    } else {
                        black += 1;
                    }
                    for k in 0..4 {
                        let nx = x as isize + dx[k];
                        let ny = y as isize + dy[k];
                        if 0 <= nx
                            && nx < w as isize
                            && 0 <= ny
                            && ny < h as isize
                            && g[y][x] != g[ny as usize][nx as usize]
                        {
                            q.push_back((ny as usize, nx as usize));
                        }
                    }
                }
                ans += white * black;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

#include<unordered_map>

int main(){
	int N;
	LL M;
	cin >> N >> M;
	map<LL, LL> mp;
	LL sum = 0;
	mp[0]++;
	LL ans = 0;
	for(int i=0; i<N; i++){
		LL a;
		cin >> a;
		sum += a;
		ans += mp[sum%M];
		mp[sum%M]++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4224
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

struct kraw
{
    int a, w;
};

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector< vector<kraw> > T(n);
    for (int i = 0; i < n - 1; ++i)
    {
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        T[a].push_back({b, c});
        T[b].push_back({a, c});
    }
    vector<int> col(n);
    vector<bool> odw(n, false);
    stack<int> S;
    odw[0] = true;
    S.push(0);
    col[0] = 0;
    while (!S.empty())
    {
        int akt = S.top();
        S.pop();
        for (int i = 0; i < T[akt].size(); ++i)
        {
            if (!odw[T[akt][i].a])
            {
                odw[T[akt][i].a] = true;
                S.push(T[akt][i].a);
                if (T[akt][i].w % 2 == 0)
                    col[T[akt][i].a] = col[akt];
                else
                    col[T[akt][i].a] = col[akt] ^ 1;
            }
        }
    }
    for (int i = 0; i < n; ++i)
        cout << col[i] << endl;
    return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N, C;
  cin >> N >> C;
  vector< vector<ll> > D(C, vector<ll>(C)), color(N, vector<ll>(N));
  REP(i, 0, C) REP(j, 0, C) cin >> D[i][j];
  REP(i, 0, N) REP(j, 0, N) cin >> color[i][j], color[i][j]--;

  vector< vector<ll> > cnt(3, vector<ll>(C, 0));
  REP(i, 0, N) REP(j, 0, N) {
    ll p = (i + j) % 3;
    cnt[p][color[i][j]]++;
  }

  ll ans = (1LL << 60);
  REP(i, 0, C) REP(j, 0, C) REP(k, 0, C) {
    if(i == j || j == k || k == i) continue;
    ll sum = 0;
    REP(l, 0, C) {
      sum += D[l][i] * cnt[0][l];
      sum += D[l][j] * cnt[1][l];
      sum += D[l][k] * cnt[2][l];
    }
    ans = min(ans, sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2176
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define sz(x) (ll)x.size()
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> osSet;

using pll = pair<ll, ll>;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

ll func(ll x){
	return (x*(x+1))/2;
}

ll _pow(ll b, ll p){
	if(p == 0) return 1;
	if(p == 1) return b;
	ll exB = b*b;
	if(p&1) return b*_pow(exB, p/2);
	return _pow(exB, p/2);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	cout << (a[0]*a[1])/2;
	return 0;
}

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

l, r = map(int, input().split())

for i in range(M-1):
    l2, r2 = map(int, input().split())
    if l2 > l:
        l = l2
    if r > r2:
        r = r2
if r - l + 1 > 0:
    print(r - l + 1)
else:
    print(0)

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

int main(){
	string s[1000];
	int c = 0;
	while(cin >> s[c]){c++;}
	int th,tm;
	int h = 0;
	int m = 0;
	for(int i=0;i<c;i++){
		if(s[i].size()>m){ m = s[i].size(); tm = i; }
		int a = 0;
		for(int j=0;j<c;j++) if(s[i]==s[j]) a++;
		if(a>h){ h = a; th = i; }
	}
	cout << s[th] << " " << s[tm] << endl;
}

Measured memory_bytes: 1192
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
string s;
int main() {
	cin >> s;
	int g1 = 0, p1 = 0;
	for (char c : s) {
		if (c == 'g') g1++;
		else p1++;
	}
	int g2 = s.size() - s.size() / 2, p2 = s.size() - g2;
	cout << g1 - g2 << endl;
	return 0;
}

Measured memory_bytes: 512
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

string[100] WS;
bool[string] MEMO;

void main()
{
    auto N = readln.chomp.to!int;
    foreach (i; 0..N) {
        WS[i] = readln.chomp;
    }
    char c = WS[0][0];
    foreach (w; WS[0..N]) {
        if (c != w[0] || w in MEMO) {
            writeln("No");
            return;
        }
        MEMO[w] = true;
        c = w[$-1];
    }
    writeln("Yes");
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100
int main(){
  int i,j,minj,tmp,N;
  int A[MAX];
  int count = 0;
  
  scanf("%d",&N);
  for( i=0 ; i<N ; i++ )
    scanf("%d",&A[i]);

  for( i=0 ; i<=N-1 ; i++ ){
    minj = i;

    for( j=i ; j<=N-1 ; j++ ){
      if(A[j] < A[minj])
	minj = j;
    }

    if(i != minj){
      count++;
      tmp = A[i];
      A[i] = A[minj];
      A[minj] = tmp;
    }
  }

    for( i=0 ; i<N-1 ; i++)
      printf("%d ",A[i]);
    printf("%d",A[N-1]);
    printf("\n%d\n",count);
  return 0;
}



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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

template<class T,class U>
istream& operator >> (istream&is, P<T,U>&v){
  is >> v.first >> v.second; v.first--; v.second--;
  return is;
}

struct UFT{
  int * p;
  
  UFT(int N):p(new int[N]){fill(p,p+N,-1);}  
  ~UFT(){delete[] p;}  
  int par(int a)   { if( p[a] >= 0 ){ p[a] = par( p[a] ); return p[a]; } return a;  }
  int size(int a)  { return -p[par(a)]; }
  bool	same(int a, int b) { return par(a) == par(b); }
  void unite(int a, int b){
    a = par(a);  b = par(b);
    if( a == b ) return;
    if( size(a) < size(b) )a^=b^=a^=b;
    p[a] -= size(b);
    p[b] = a;
  }
};


int main(){
  int n,m,k; cin >> n >> m >> k;
  vector<P<int,int>> fri(m); cin >> fri;
  vector<P<int,int>> bad(k); cin >> bad;
  map<int,int> frir;
  map<int,vector<int>> badr;
  UFT uft(n);
  for(auto e:fri){
    frir[e.first]++;
    frir[e.second]++;
    uft.unite(e.first, e.second);
  }
  for(auto e:bad){
    badr[e.first].push_back(e.second);
    badr[e.second].push_back(e.first);
  }
  

  for(int i = 0; i < n; ++i){
    if(i)cout << ' ';
    int ans = uft.size(i)-1;
    ans -= frir[i];
    for(auto e:badr[i]){
      if(uft.same(i,e))ans--;
    }
    cout << ans;
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 18176
input()
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
li  = list(map(int,input().split(" ")))
s  = lcm(li[0],li[1])
for i in range(len(li)-2):
    s = lcm (s,li[i+2])
def f(m):
    r = 0
    for i  in li:
        r += m%i
    return r
print(f(s-1))


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

int main() {
  char S;
  cin >> S;
  if (S == 'A' || S == 'B' || S == 'C' || S == 'D' || S == 'E') {
    cout << "A" << endl;
  }
  if (S == 'F' || S == 'G' || S == 'H' || S == 'I' || S == 'J') {
    cout << "A" << endl;
  }
  if (S == 'K' || S == 'L' || S == 'M' || S == 'N' || S == 'O') {
    cout << "A" << endl;
  }
  if (S == 'P' || S == 'Q' || S == 'R' || S == 'S' || S == 'T') {
    cout << "A" << endl;
  }
  if (S == 'U' || S == 'V' || S == 'W' || S == 'X' || S == 'Y' || S == 'Z') {
    cout << "A" << endl;
  }
  if (S == 'a' || S == 'b' || S == 'c' || S == 'd' || S == 'e') {
    cout << "a" << endl;
  }
  if (S == 'f' || S == 'g' || S == 'h' || S == 'i' || S == 'j') {
    cout << "a" << endl;
  }
  if (S == 'k' || S == 'l' || S == 'm' || S == 'n' || S == 'o') {
    cout << "a" << endl;
  }
  if (S == 'p' || S == 'q' || S == 'r' || S == 's' || S == 't') {
    cout << "a" << endl;
  }
  if (S == 'u' || S == 'v' || S == 'w' || S == 'x' || S == 'y' || S == 'z') {
    cout << "a" << endl;
  }
}

Measured memory_bytes: 3588
import java.util.Scanner;


public class Main {
	private static int n;
	private static int K;
	private static int[] A;
	private static long[] B;
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		K = in.nextInt();
		
		A = new int[n];
		B = new long[n];
		long rs = 0;
		for(int i=0;i<n;i++){
			A[i] = in.nextInt();
			B[i] = in.nextLong();
			
			if((K&A[i])==A[i]){
				rs = rs + B[i];
			}
		}
		
		for(int i=30;i>=0;i--){
			int tmp = 1<<i;
			
			if( (K&tmp) == tmp ){
				
				int x = (K^tmp)|(tmp-1);
				long ans  = 0;
				
				for(int j=0;j<n;j++){
					if( (x&A[j]) == A[j]){
						ans = ans + B[j];
					}
				}
				rs = ans>rs?ans:rs;
			}
		}
		System.out.println(rs);
		
	}
}


Measured memory_bytes: 89948
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	REP(i, H) cin >> S[i];
	REP(i, H) {
		REP(j, W) {
			if (S[i][j] == '#') continue;
			int cnt = 0;
			for (int k = i - 1;k <= i + 1;k++) {
				if (k < 0 || k >= H) continue;
				for (int l = j - 1;l <= j + 1;l++) {
					if (l < 0 || l >= W) continue;
					if (S[k][l] == '#') cnt++;
				}
			}
			S[i][j] = '0' + cnt;
		}
	}
	REP(i, H) cout << S[i] << "\n";

	return 0;
}

Measured memory_bytes: 256