akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

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

        int n = sc.nextInt();

        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();

        }

        Arrays.sort(a);
        if (a.length == 2) {
            System.out.println(Math.max(a[0], a[1]));
            return;
        }

        //a0カエルケース
        int gcd1 = gcd(a[1], a[2]);
        for (int i = 1 ; i < n ; i++) {
            gcd1 = gcd(gcd1, a[i]);
        }

        //a0変えないケース、a0の約数を求めたいお気持ち
        Set<Integer> set = new HashSet<>();
        double flor = Math.floor(Math.sqrt(a[0]));
        for (int i = 1 ; i <=  flor ; i++) {
            if (a[0] % i == 0) {
                set.add(i);
                set.add(a[0] / i);
            }
        }


        int max = 1;

        for (Integer i : set) {
            int count = 0;
            for (int j = 1 ; j < n ; j++) {
                if (a[j] % i != 0) {
                    count++;
                }

            }
            if (count <= 1) {
                max = Math.max(max, i);
            }
        }

        System.out.println(Math.max(gcd1, max));
    }

    private static int gcd(int m, int n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

}

Measured memory_bytes: 50436
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long ans=0;
    int n,i=0,a[200009];
    for(scanf("%d",&n); i<n; ++i) scanf("%d",a+i),a[i]-=i;
    for(sort(a,a+n),i=0; i<n; ++i) ans+=abs(a[n/2]-a[i]);
    printf("%lld\n",ans),exit(0);
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 2 * 1'00'000 + 5;

i64 x, y, a, b, c;

i64 p[MAXN];
i64 q[MAXN];
i64 r[MAXN];

pair<i64, i64> qr[MAXN];

i64 pp[MAXN];
i64 pqr[MAXN];
i64 pr[MAXN];


int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);


    cin >> x >> y >> a >> b >> c;

    for (i64 i = 1; i <= a; i++) {
        cin >> p[i];
    }

    for (i64 i = 1; i <= b; i++) {
        cin >> q[i];
    }

    for (i64 i = 1; i <= c; i++) {
        cin >> r[i];
    }

    for (i64 i = 1; i <= b; i++) {
        qr[i] = { q[i], false };
    }
    for (i64 i = 1; i <= c; i++) {
        qr[b + i] = { r[i], true };
    }

    sort(p + 1, p + a + 1, greater<i64>());
    sort(qr + 1, qr + b + c + 1, greater<pair<i64, i64>>());
    sort(r + 1, r + c + 1, greater<i64>());

    for (i64 i = 1; i <= a; i++) {
        pp[i] = pp[i - 1] + p[i];
    }

    for (i64 i = 1; i <= b + c; i++) {
        pqr[i] = pqr[i - 1] + qr[i].first;
    }

    for (i64 i = 1; i <= c; i++) {
        pr[i] = pr[i - 1] + r[i];
    }

    i64 ci = 0;
    for (i64 i = 1; i <= y; i++) {
        ci += qr[i].second ? 1 : 0;
    }

    i64 ui = 0;
    i64 R = 0;
    for (i64 i = 0; i <= min(x, c); i++) {
        //i64 tr = pp[x - i] + pqr[y + ui] - pr[ui];
        i64 tr = pp[x - i] + pqr[y + ui] - pr[ui] + pr[i];
        R = max(R, tr);

        if (ci > 0) {
            ci -= 1;
            ui += 1;
            ci += qr[y + ui].second ? 1 : 0;
        }
    }

    cout << R << endl;




    return 0;
}

Measured memory_bytes: 11776
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scan =new Scanner(System.in);

        int N= scan.nextInt();
        int A[] = new int[N];
int B[]=new int[N];

int i2=0;

while (i2<N)
{A[i2]=0;
i2=i2+1;
}
int i1=1;

 while(i1<N){
     B[i1]=scan.nextInt()-1;
     i1=i1+1;

 }
        int i=1;
        while (i<N) { A[B[i]]=A[B[i]]+1;
        i=i+1;


        }
int i3=0;
while (i3<N){System.out.println(A[i3]);
i3=i3+1;

}


    }
}

Measured memory_bytes: 61184
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define REP(i, n) for (int i(0); i < n; ++i)
#define REQ(i, a, b) for (int i(a); i <= b; ++i)


signed main(){
	ios_base::sync_with_stdio(0);
	char c;
	cin >> c;
	cout << char((int)c +1);
		
}

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

//#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using pii = pair<int, int>; using vi = vector<int>;
static const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
static const int MOD = (int)(1e9 + 7);

signed main() {
	for (int q1, b, c1, c2, q2; cin >> q1 >> b >> c1 >> c2 >> q2&&q1;) {
		int money = b;
		int aizu_m = min(q2, money / c1);
		money -= aizu_m*c1;
		int normal_m = money / c2;
		money -= normal_m*c2;
		bool NA = false;
		while (aizu_m + normal_m < q1) {
			if (aizu_m <= 0) {
				NA = true;
				break;
			}
			aizu_m -= 1;
			money += c1;
			int normal_m_add = money / c2;
			normal_m += normal_m_add;
			money -= normal_m_add*c2;
		}
		if (aizu_m == 0)NA = true;
		if (NA) {
			cout << "NA" << endl;
			continue;
		}
		cout << aizu_m << " " << normal_m << endl;
	}
	return 0;
}

Measured memory_bytes: 2984
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (ll& i : a) cin >> i;
    sort(a.begin(), a.end(), greater<>());
    ll r = 0;
    for (int i = 1; i < n; ++i) {
        r += a[i/2];
    }
    cout << r << endl;
}

Measured memory_bytes: 4800
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int m,r,f;
		char c;
		while(true){
			m=sc.nextInt();
			f=sc.nextInt();
			r=sc.nextInt();
			if(m==-1&&r==-1&&f==-1)System.exit(0);
			if(m==-1||f==-1)c='F';
			else if(m+f>=80)c='A';
			else if(m+f>=65)c='B';
			else if(m+f>=50)c='C';
			else if(m+f>=30){
				if(r>=50)
					c='C';
				else
					c='D';
			}else c='F';
			System.out.println(c);
		}
	}
}


Measured memory_bytes: 26272
// AOJ 2199: Differential Pulse Code Modulation
// 2017.9.21 bal4u@uu
// 2017.11.22

#include <stdio.h>
#include <string.h>

#define INF 1152921504606846976LL
int code[18];			// code book
char y[2][260];			// signal
long long ss[2][260];	// Sum of Squares
int t2[256];

char buf[20], *p;
int getint()
{
	int n = 0;
	if (*p == '-') {
		p++;
		while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
		return -n;
	}
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}
int main()
{
	int n, m, i, j, k, x, tt, k1, k2;
	long long ans, s;

	for (i = 0; i < 256; i++) t2[i] = i*i;

	while (fgets(p=buf, 20, stdin) && *p != '0') {
		n = getint(), p++, m = getint();
		for (j = 0; j < m; j++) {
			fgets(p=buf, 10, stdin);
			code[j] = getint();
		}
		memset(ss, 0x55, sizeof(ss)), memset(y, 0, sizeof(y)); y[0][128] = 1, ss[0][128] = 0;
		for (k1 = 0, k2 = 1, k = 0; k < n; k++, k1 = k2, k2 = !k2) {
			memset(y[k2], 0, sizeof(y[k2]));
			memset(ss[k2], 0x55, sizeof(ss[k2]));
//			for (i = 0; i < 256; i++) y[k2][i] = 0, ss[k2][i] = INF;
			fgets(p=buf, 10, stdin), x = getint();
			for (i = 0; i < 256; i++) if (y[k1][i]) {
				for (j = 0; j < m; j++) {
					int t = i + code[j];
					if (t < 0) t = 0;
					if (t >= 256) t = 255;
					y[k2][t] = 1;
					tt = t-x; if (tt < 0) tt = -tt;
					s = t2[tt] + ss[k1][i];
					if (s < ss[k2][t])	ss[k2][t] = s;
				}
			}
		}
		for (ans = 1LL << 60, i = 0; i < 256; i++) 
			if (ss[k1][i] < ans) {
				ans = ss[k1][i]; if (ans == 0) break;
			}
		printf("%lld\n", ans);
	}
	return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int L, R;

signed main()
{
  cin >> L >> R;
  if(R-L > 3000) {
    cout << 0 << endl;
    return 0;
  } else {
    int ans = 1145141919;
    FOR(i,L,R+1) {
      FOR(j,i+1,R+1) {
        ans = min(i*j%2019, ans);
      }
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << x << endl;
#else 
    #define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int five(int a) {

    return a * a * a * a * a; 
} 


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int x;
    cin >> x;
    for (int a = -300; a <= 300; ++a) {
        for (int b = -300; b < a; ++b) {
            if (five(a) - five(b) == x) {
                cout << a << ' ' << b << '\n'; 
                return 0;
            }
        }
    }
    assert(x == -228);

}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  long long n;
  cin >> n;
  vector<vector<string> > vec(n);
  vec[0].push_back("a");
  for(int i=1;i<n;i++){
    for(size_t j=0;j<vec[i-1].size();j++){
      string s=vec[i-1][j];
      int charcnt[30]={},cnt=0;
      for(size_t k=0;k<s.size();k++){
        if(charcnt[s[k]-'a']==0) cnt++;
        charcnt[s[k]-'a']++;
      }
      for(int k=0;k<cnt+1;k++){
        string t=s;
        t+='a'+k;
        vec[i].push_back(t);
      }
    }
  }
  for(size_t i=0;i<vec[n-1].size();i++){
    cout << vec[n-1][i] << endl;
  }
  return 0;
}

Measured memory_bytes: 11380
#include <iostream>
using namespace std;
int main(void) {
	int a, b;
	cin >> a >> b;
	int ma = a * -1;
	int mb = b * -1;
	int c = 2e9, d = 2e9, e = 2e9, f = 2e9;
	if (a < b) c = b - a;
	if (a <= mb) d = mb - a + 1;
	if (ma <= b) e = b - ma + 1;
	if (ma <= mb) f = mb - ma + 2;
	int ans = min(c, min(d, min(e, f)));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N, ans = 0;
  std::cin >> N;
  std::vector<int> A(N+1), B(N+1);
  vvi lr = vv(N+1, 2, 0, int);
  for(int i=1;i<=N;i++) {
    std::cin >> A[i];
    B[A[i]] = i;
  }
  set<int> zahyo;
  //-------------------------------------------------------------------
  for(int i=1;i<=N;i++){
    if(zahyo.lower_bound(B[i])==zahyo.end()) lr[B[i]][1] = N - B[i];
    else {
      auto itr = zahyo.lower_bound(B[i]);
      lr[B[i]][1] = *itr - B[i] - 1;
    }
    if(zahyo.lower_bound(B[i])==zahyo.begin()) lr[B[i]][0] = B[i]-1;
    else{
      auto itr = zahyo.lower_bound(B[i]);
      itr--;
      lr[B[i]][0] = B[i] - *itr - 1;
    }
    zahyo.insert(B[i]);
  }
  //for(int i=1;i<=N;i++) std::cout << lr[i][0] << " " << lr[i][1] << '\n';
  //-------------------------------------------------------------------
  for(int i=1;i<=N;i++) ans += A[i] * (lr[i][0]+1) * (lr[i][1]+1);
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 22144
import bisect
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

class Node:
    def __init__(self, val, idx=0):
        self.val = val
        self.idx = idx

    def __str__(self):
        return 'val : ' + str(self.val) + ' idx : ' + str(self.idx)

# 0-idxed SegmentTree
class SegmentTree:
    def __init__(self, N, vals, default_value=INF):
        self.N0 = pow(2, (N-1).bit_length())
        self.nodes = [Node(default_value, i+1-self.N0)
                      for i in range(2*self.N0-1)]
        for i in reversed(range(2*self.N0-1)):
            ind = i+1-self.N0
            if ind >= N:
                self.nodes[i].val = default_value
            elif ind >=0 and N > ind:
                self.nodes[i].val = vals[ind]
            else:
                self.nodes[i] = self.propagate(
                    self.nodes[i*2+1], self.nodes[i*2+2])

    def __getitem__(self, key):  # getiten : ST[i]
        return self.nodes[key+self.N0-1].val

    def __setitem__(self, i, x):  # update : ST[i] = x
        i += self.N0 - 1
        self.nodes[i].val = x
        while i > 0:
            i = (i-1)//2
            self.nodes[i] = self.propagate(self.nodes[i*2+1], self.nodes[i*2+2])

    def __str__(self):
        return '['+', '.join(map(str, [self.nodes[i+self.N0-1].val for i in range(self.N0)]))+']'

    def query(self, L, R):  #value of [L,R)
        retnode = Node(0, 0)
        L += self.N0
        R += self.N0
        while L < R:
            if R & 1:
                R -= 1
                retnode = self.propagate(retnode, self.nodes[R-1])
            if L & 1:
                retnode = self.propagate(retnode, self.nodes[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return retnode

    def propagate(self, node_x, node_y):  # return parent if x,y is child
        return Node(node_x.val | node_y.val)


def main():
    N = iRaw()
    S = sRaw()
    sgt = SegmentTree(N, [1 << (ord(s)-ord('a')) for s in S])
    Q = iRaw()
    ans =[]
    for _ in range(Q):
        t,l,r = ssRaw()
        if t=="1":
            sgt[int(l)-1] = 1 << (ord(r)-ord("a"))
        else:
            ret = sgt.query(int(l)-1, int(r))
            ans.append(str(bin(ret.val)).count("1"))
    return "\n".join(map(str, ans))

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


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

j = 0
S = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, input().split())
    S[L][R] += 1
for i in range(1, N + 1):
    for j in range(1, N + 1):
        S[i][j] += S[i][j - 1]
for i in range(1, N + 1):
    for j in range(1, N + 1):
        S[i][j] += S[i - 1][j]

for i in range(Q):
    p, q = map(int, input().split())
    print(S[q][q] + S[p - 1][p - 1] - S[p - 1][q] - S[q][p - 1])


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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  string S; cin >> S;
  int ans;
  if(S == "RRR"){
    ans = 3;
  } else if(S == "RRS" || S == "SRR"){
    ans = 2;
  } else if(S == "RSS" || S == "SRS" || S == "SSR" || S == "RSR"){
    ans = 1;
  } else {
    ans = 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
### main

while true
  n = gets.strip.to_i
  break if n == 0

  counts = 10.times.map{0}

  n.times.each do
    k = gets.strip.to_i
    counts[k] += 1
  end

  for c in counts
    puts (c > 0 ? "*" * c : '-')
  end
end

Measured memory_bytes: 6096
#include <iostream>
#include <string>
using namespace std;
#define NUM 50
#define MAXL 50

int main(){
    char grid[NUM][MAXL + 1];
    int h, w;
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        cin >> grid[i];
    }
    
    int judge = 0, num_black = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; grid[i][j] != '\0'; j++){
            if(grid[i][j] == '#'){
                num_black++;
                int check[4];
                check[0] = (i > 0 && grid[i - 1][j] == '#')? 1 : 0;
                check[1] = (i < h - 1 && grid[i + 1][j] == '#')? 1 : 0;
                check[2] = (j > 0 && grid[i][j - 1] == '#')? 1 : 0;
                check[3] = (j < w - 1 && grid[i][j + 1] == '#')? 1 : 0;
                judge = check[0] + check[1] + check[2] + check[3];
                //cout << "judge = " << judge << endl;
                if(judge == 0){
                    goto END;
                }
            }
        }
    }

END:
    if(judge > 0 || num_black == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    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 A = sc.nextInt();
    String op = sc.next();
    int B = sc.nextInt();
 
    if(op.equals("+")){
    System.out.println(A + B);
    }else{
    System.out.println(A - B);
    }
  }
}
      

Measured memory_bytes: 35808
def II(): return int(input())
def MI(): return map(int, input().split())
N=II()
shogens=[]
for i in range(N):
  a=II()
  shogens.append([])
  for j in range(a):
    x,y=MI()
    x-=1
    shogens[-1].append((x,y))
def is_honest(i,j):
  return (i>>j)%2==1
def honest_cnt(i):
  ans=0
  for j in range(N):
    ans+=is_honest(i,j)
  return ans
ans=0
for i in range(1<<N):
  ok=True
  for j in range(N):
    if not is_honest(i,j):
      continue
    for (x,y) in shogens[j]:
      if y==0 and is_honest(i,x):
        ok=False
      if y==1 and not is_honest(i,x):
        ok=False  
  if ok:
    ans=max(ans,honest_cnt(i))
print(ans)

Measured memory_bytes: 9148
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

typedef pair<int, int> P;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vector<int> a(n);
    priority_queue<P> que;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        que.push(P(abs(a[i]), i));
    }
    int id = que.top().second;
    int max_ele = a[id];
    
    vector<P> ans;
    if(a[id] > 0){
        for(int i = 0; i < n; ++i){
            if(a[i] == max_ele)     continue;
            
            a[i] += max_ele;
            ans.push_back(P(id, i));
        }
        for(int i = 1; i < n; ++i){
            if(a[i] < a[i - 1]){
                a[i] += a[i - 1];
                ans.push_back(P(i - 1, i));
            }
        }
    }
    else if(a[id] < 0){
        for(int i = 0; i < n; ++i){
            if(a[i] == max_ele)     continue;
            
            a[i] += max_ele;
            ans.push_back(P(id, i));
        }
        for(int i = n - 2; i >= 0; --i){
            if(a[i] > a[i + 1]){
                a[i] += a[i + 1];
                ans.push_back(P(i + 1, i));
            }
        }
    }
    
    int m = ans.size();
    cout << m << endl;
    for(int i = 0; i < m; ++i){
        cout << ans[i].first + 1 << " " << ans[i].second + 1 << "\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){

	int N,M,R;
	cin>>N>>M>>R;
	
	vector<vector<int>> dis(N,vector<int>(N,Inf));
	
	vector<int> r(R);
	
	for(int i=0;i<R;i++){
		cin>>r[i];
		r[i]--;
	}
	
	for(int i=0;i<M;i++){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		dis[a][b] = min(dis[a][b],c);
		dis[b][a] = min(dis[b][a],c);
	}
	
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			for(int k=0;k<N;k++){
				if(dis[j][k] > dis[j][i] + dis[i][k]){
					dis[j][k] = dis[j][i] + dis[i][k];
				}
			}
		}
	}
	
	sort(r.begin(),r.end());
	int ans = Inf;
	
	do{
		int cost = 0;
		for(int i=0;i<r.size()-1;i++){
			cost += dis[r[i]][r[i+1]];
		}
		ans = min(cost,ans);
	}
	while(next_permutation(r.begin(),r.end()));
	
	cout<<ans<<endl;
	
    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
#define REP(i,st,ed) for(int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(int i=st,i##end=ed;i>=i##end;--i)
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<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
const int maxn=55;
char s[maxn];
int main(){
	scanf("%s",s);
	REP(i,0,strlen(s)-9)
		printf("%c",s[i]);
	puts("");
	return 0;
}

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

int A,B,C;

int beki(int n){
	int count = 0;
	while(n%2==0){
		count++;
		n /= 2;
	}
	return count;
}

int main(){
	cin >> A >> B >> C;
	if(A%2==1 || B%2==1 || C%2==1) cout << 0 << endl;
	else if(A==B && B==C) cout << -1 << endl;
	else{
		int ans = 1e9;
		cout << min(beki(A+B),min(beki(B+C),beki(C+A))) << endl;
	}
}

Measured memory_bytes: 256
# 整数の入力
numbers = int(input())
#２つ目の標準入力をいれる
# こんなかんじではいる[1, 4, 6, 3]
list_numbers = list(map(int, input().split()))

#maxの値を入れる
#最初は０で定義しておく
max = 0


# for文で回して一個ずつ確かめる
for number in range(numbers):
	
	for number2 in range(numbers):
		result = list_numbers[number]-list_numbers[number2]
        #絶対値なので０未満だったらマイナスつけておく
		if result < 0:
			result = -1*result
        #いままで出てきたどの結果よりも大きい値であればmaxを更新する
		if result > max:
			max = result

print(max)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <vector>
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define INF 0x3fffffff
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == 5 && b == 5 && c == 7) {
		cout << "YES" << endl;
		return 0;
	}
	if (a == 5 && b == 7 && c == 5) {
		cout << "YES" << endl;
		return 0;
	}
	if (a == 7 && b == 5 && c == 5) {
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;



void solve(){
    char a,b;
    cin >> a >> b;
    if(a==b) cout << "H" << endl;
    else cout << "D" << endl;
}

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

Measured memory_bytes: 256
require 'prime'
n = gets.to_i
move_counts = []
if Prime.prime?(n)
    move_counts << n - 1
else
    (2..Math.sqrt(n).to_i).each do |a|
        if n % a == 0
            b = n / a
            move_counts << a + b - 2
        end
    end
end
puts move_counts.min

Measured memory_bytes: 2172
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n; cin >> n;
    lli r = ceil(sqrt(n));
    lli ans = INFLL;
    for(lli i=1; i<=r; i++) if(n%i == 0) chmin(ans, (i-1)+(n/i-1));
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for(int i=0;i<N;i++){
    cin >> h.at(i);
  }
  vector<int> dp(N);
  dp.at(0)=0;
  dp.at(1)=abs(h[1]-h[0]);
  
  for(int i=2;i<N;i++){
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
  }
  cout << dp.at(N-1) << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
using ll = long long;
using ld = long double;

int n, q;
string s;
vector<pair<char, char>> qs;
int eval(int x) {
  for (const auto& p : qs) {
    if (s[x] == p.first) {
      (p.second == 'L' ? x-- : x++);
      if (x < 0) return -1;
      if (x >= n) return 1;
    }
  }
  return 0;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q >> s;
  while (q--) {
    char t, d; cin >> t >> d;
    qs.emplace_back(t, d);
  }
  //for (int i = 0; i < n; i++) cerr << eval(i) << " "; cerr << nl;
  int good = -1;
  int l = 0, r = n-1;
  while (l <= r) {
    int m = (l+r)/2;
    int res = eval(m);
    if (res == 0) {
      good = m;
      break;
    } else if (res == -1) {
      l = m+1;
    } else r = m-1;
  }
  if (good == -1) {
    puts("0");
    return 0;
  }
  int mn = -1;
  l = 0, r = good;
  while (l <= r) {
    int m = (l+r)/2;
    int res = eval(m);
    if (res == 0) {
      mn = m;
      r = m-1;
    } else l = m+1;
  }
  assert(mn != -1);
  int mx = -1;
  l = good, r = n-1;
  while (l <= r) {
    int m = (l+r)/2;
    int res = eval(m);
    if (res == 0) {
      mx = m;
      l = m+1;
    } else r = m-1;
  }
  //cerr << mx << " " << mn << nl;
  cout << mx - mn + 1 << nl;
  return 0;
}


Measured memory_bytes: 1100
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    string s;
    cin >> s;
    Int len = (Int)s.length();
    if (len == 2) {
    } else if (len == 3) {
        std::reverse(s.begin(), s.end());
    }
    cout << s << endl;
    return 0;
}


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

/*int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0;i<N;i++){
        cin >> d.at(i);
    }
    sort(d.begin(),d.end());
    int c=1;
    for(int i=1;i<N;i++){
        if(d.at(i)!=d.at(i-1)) c++;
    }
    cout << c << endl;
    return 0;
}*/
int main(){
int N,Y;
int x,y,z;
cin >> N >> Y;
    for(x=Y/10000;x>=0;x--){
    for(y=(Y-x*10000)/5000;y>=0;y--){
    z=N-x-y;
    if(10000*x+5000*y+1000*z==Y) {
        cout<<x<<" "<<y<<" "<<z<<endl;
        return 0;
    }
    }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int>VI;
const int N=4e4,mo=998244353;
inline int poww(int x,int y){
	int ans=1;
	for(;y;y>>=1,x=1ll*x*x%mo)if(y&1)ans=1ll*ans*x%mo;
	return ans;
}
struct NTT{
	int b[N],wn[N],l,invl;
	inline void ini(int n){
		invl=poww(l=n,mo-2);int i;
		for(i=1;i<l;++i)b[i]=b[i>>1]>>1|(i&1?l>>1:0);
		for(i=2,wn[*wn=1]=poww(3,(mo-1)/l);i<=l;++i)wn[i]=1ll*wn[i-1]*wn[1]%mo;
	}
	inline void DFT(int*a,int key){
		static int c[N],w[N];int i,j,k,m,u;
		memcpy(c,a,l<<2);for(i=0;i<l;++i)a[b[i]]=c[i];
		for(i=2;i<=l;i<<=1){
			for(j=k=0,m=i>>1;k<m;j+=l/i,++k)w[k]=wn[j];
			for(j=0;j<l;j+=i)for(k=0;k<m;++k)u=1ll*a[j+k+m]*w[k]%mo,
				a[j+k+m]=a[j+k]-u,a[j+k+m]+=a[j+k+m]>>31&mo,a[j+k]+=u-mo,a[j+k]+=a[j+k]>>31&mo;
		}		
		if(key==-1)for(reverse(a+1,a+l),i=0;i<l;++i)a[i]=1ll*a[i]*invl%mo;
	}
}F[20];
int lo[N];
inline void getinv(int*A,int n){
	static int B[N],C[N];int i,j;
	memset(B,0,8<<n);*B=poww(*A,mo-2);
	for(i=1;i<=n;++i){
		memcpy(C,A,4<<i);F[i+1].DFT(B,1);F[i+1].DFT(C,1);
		for(j=0;j<F[i+1].l;++j)B[j]=(2ll*B[j]+mo-1ll*C[j]*B[j]%mo*B[j]%mo)%mo;F[i+1].DFT(B,-1);
		memset(B+(1<<i),0,4<<i);memset(C,0,8<<i);
	}
	memcpy(A,B,4<<n);
}
inline void mul(const int*a,const int*b,int*c,int n,int m){
	static int A[N],B[N];int i,l=lo[n+m-1];
	memset(A,0,4<<l);memset(B,0,4<<l);memcpy(A,a,n<<2);memcpy(B,b,m<<2);
	F[l].DFT(A,1);F[l].DFT(B,1);for(i=0;i<1<<l;++i)A[i]=1ll*A[i]*B[i]%mo;
	F[l].DFT(A,-1);memcpy(c,A,n+m-1<<2);
}
int fac[N],i,a,b;
char c1[N],c2[N];
inline VI mul(const VI&a,const VI&b){
	static VI c;c.resize(a.size()+b.size()-1);
	mul(&a[0],&b[0],&c[0],a.size(),b.size());c.resize(::a+1);return c;
}
int main(){
	for(i=0;i<16;++i)F[i].ini(1<<i);for(i=2;i<N;++i)lo[i]=lo[i-1]+!((i-2)&(i-1));
	for(i=*fac=1;i<N;++i)fac[i]=1ll*fac[i-1]*i%mo;
	scanf("%s%s",c1+1,c2+1);
	for(i=1;c1[i];++i)a+=c1[i]=='1' && c2[i]=='1',b+=c1[i]!=c2[i];b/=2;
	VI A,B;A.resize(a+1);B={1};for(i=0;i<=a;++i)A[i]=poww(fac[i+1],mo-2);
	for(i=b;i;i>>=1,A=mul(A,A))if(i&1)B=mul(B,A);
	i=0;for(int x:B)i=(i+x)%mo;i=1ll*fac[a]*fac[b]%mo*fac[a+b]%mo*i%mo;
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const int N = 1e5+10;

using namespace std;

main()
{
    fast;
    int x,y;
    int mark[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
    cin>>x>>y;
    if (mark[x]==mark[y])
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n, m;
  cin >> n >> m;
  vector<long> v(m);
  rep(i, m) {
    long p, y;
    cin >> p >> y;
    v[i] = (p << 32) | y;
  }

  vector<long> sorted_v(v);
  sort(sorted_v.begin(), sorted_v.end());

  unordered_map<long, vector<long>::iterator> head;
  rep(i, m) {
    const long p = v[i] >> 32;
    if (head.find(p) == head.end()) {
      head[p] = lower_bound(sorted_v.begin(), sorted_v.end(), p << 32);
    }
    auto it2 = lower_bound(head[p], sorted_v.end(), v[i]);
    auto d = distance(head[p], it2);
    printf("%06ld%06ld\n", p, d + 1); 
  }
  return 0;
}


Measured memory_bytes: 7204
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
#define stoi stoll
const signed INF_=1001001001; const int INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n=IN;
    int cnt=0;
    REP(i,n) {
        int a=IN;
        cnt+=a%2;
    }
    cout<<(cnt%2==0?"YES":"NO")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, X;
  cin >> N >> X;
  vector<int> data(N,-X);
  int a;
  for (int i = 0; i < N; i++) {
    cin >> a;
    data.at(i) += a;
    data.at(i) = abs(data.at(i));
  }
  int A, B, ans = data.at(0);
  for (int i = 0; i < N; i++) {
    A = ans;
    B = data.at(i);
    if (B % A == 0) continue;
    while (A != B) {
      if (A > B) A -= B;
      else B -= A;
    }
    ans = A;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
    int i, j, H, W;
    while (cin >> H >> W)
    {
        if (H==0&&W==0) break;
        
        
    
    for ( i = 0; i < H; i++)
    {
    
        for ( j = 0; j < W; j++)
        {
            if (i%2==0)
            {
                if (j%2==0)
                {
                    cout << "#";
                }else
                {
                    cout << ".";
                }

            }else
            {
                if (j%2==0)
                {
                    cout << ".";
                }else
                {
                    cout << "#";
                }
            }
            
        }
        cout << "\n";
        
    
    }
    cout << "\n";
        
    }

    

    
	return 0;
}


Measured memory_bytes: 3072
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>

#define int int64_t

using namespace std;

int gcd(int a, int b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}


signed main()
{
    int n;
    cin >> n;
   
    vector<int> v, forward, back;
    
    v.resize(n);
    
    for (int &x: v) {
        cin >> x;
    }
    
    if (n == 2) {
        cout << max(v[0], v[1]) << endl;
        return 0;
    }
    
    forward.push_back(v[0]);
    for (size_t i = 1; i < v.size(); i++) {
        forward.push_back(gcd(v[i], forward.back()));
    }
    
    back.push_back(v.back());
    for (int i = (int)v.size() - 2; i >= 0; i--) {
        back.push_back(gcd(v[i], back.back()));
    }
    reverse(back.begin(), back.end());
    
    int ans = max(forward[n-2], back[1]);
    for (int i = 1; i < n - 1; i++) {
        int a = gcd(back[i + 1], forward[i - 1]);
        if (ans < a) {
            ans = a;
        }
    }
    
    cout << ans << endl;
    return 0;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main() {
	int A = 0;
	int B = 0;
	int count = 0;
	int result = 1;
	cin >> A >> B;
	while (B > result) {
		result = result + A -1;
		count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=1
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	n, m = tin()
	al = lin()
	#s = input()
	al.sort()
	diff_al = [abs(vj-vi) for vi, vj in zip(al, al[1:])]
	#pa(al)
	#pa(diff_al)
	diff_al.sort()
	#pa(diff_al)
	if n == 1:
		ret = sum(diff_al)
	else:
		ret = sum(diff_al[:-(n-1)])
	print(ret)
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int main(){
    int a, b, k;
    cin >>k>> a >> b;
    for (int i = a;i<=b;i++){
        if(i%k==0){
            cout << "OK"<<endl;
            return 0;
        }
    }

    cout << "NG" << endl;
    return 0;
}

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

int main(){

  int N;
  cin >> N;
  vector<string> a(110);
  for(int i=0; i<N; i++) cin >> a[i];
  bool flg=1;
  
  for(int i=0; i<N-1; i++){
  	if(a[i].back() !=a[i+1].front()) {
      flg=0;
    }
  }

  for(int i=0; i<N-1; i++){
  	for(int j=1; j<N-i; j++){
    	if(a[i]==a[i+j]) flg=0;
    }  
  }
  
  
  
  
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import *

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
sa = set(A)
sb = set(B)
row, col = 0, 0
ans = 1
MOD = 10**9+7

for i in range(N*M, 0, -1):
    if (i in sa) and (i in sb):
        row += 1
        col += 1
    elif (i not in sa) and (i in sb):
        ans *= row
        col += 1
    elif (i in sa) and (i not in sb):
        ans *= col
        row += 1
    else:
        ans *= row*col-(N*M-i)
    
    ans %= MOD

print(ans)


Measured memory_bytes: 41324
from math import sin, cos, pi


def main():
    a, b, h, m = map(int, input().split())

    a_theta = (60 * h + m) * pi / 360
    b_theta = (60 * h + m) * pi / 30

    a_x = a * sin(a_theta)
    a_y = a * cos(a_theta)
    b_x = b * sin(b_theta)
    b_y = b * cos(b_theta)

    ans = ((a_x - b_x) ** 2 + (a_y - b_y) ** 2) ** 0.5

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62756
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
    int N, M;
    cin>>N>>M;
    int edge[N][N];
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            edge[i][j] = 0;
        }
    }
    int a, b;
    for(int i=0;i<M;++i){
        cin>>a>>b;
        a--;
        b--;
        edge[a][b] = 1;
        edge[b][a] = 1;
    }
    vector<int> node;
    for(int i=0;i<N;++i){
        node.push_back(i);
    }
    int ans = 0;
    bool ok;
    do {
        ok = true;
        for(int i=0;i<N-1;++i){
            if(edge[node[i]][node[i+1]]==0) ok = false;
        }
        if(ok) ans++;
    }while(next_permutation(node.begin()+1, node.end()));
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

int W, H, N;
pii p[112345];
int dp[112345];

int main() {
	cin >> W >> H >> N;
	REP(i, N) scanf("%d %d", &p[i].fi, &p[i].se);
	sort(p, p + N);
	
	for (int i = N - 2; i >= 0; i--) chmax(dp[i], max(dp[i + 1], p[i + 1].se));
	
	int ans = max(p[0].se, dp[0]);
	REP(i, N) chmin(ans, p[i].fi + dp[i]);
	cout << ans << endl;
	
	return 0;
}

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

// Caleb Faith Adnaka XI105
int main() {

    int N,R;
    cin >> N;
    cin >> R;

    if (N >= 10){
        cout << R << "\n";
    }
    else{
        cout << R + (100 * (10-N)) << "\n";
    }

}


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

int main() {
    int n,m,x,temp,res=0,ans=0;
    cin>>n>>m>>x;
    vector<int> a(n+1,0);
    rep(i,m) {
        cin>>temp;
        a[temp]++;
    }
    for (int i=1; i<x; i++) res+=a[i];
    for (int i=x+1; i<n+1; i++) ans+=a[i];
    ans=min(ans,res);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define ll long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bn begin()
#define en end()
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007
#define pi 3.141592653589
using namespace std;

int power(int x, int y) ;
int gcd(int a, int b) ;

signed main() {
	quickie
	int n, d ;
	cin >> n >> d ;
	int ans = 0 ;
	rep(i, 0, n) {
		db a, b ;
		cin >> a >> b ;
		a *= a ;
		b *= b ;
		a += b ;
		db p = sqrt(a) ;
		if(p <= d) ans++ ;
	}
	cout << ans << "\n" ;
}

int power(int x, int y) {
	int res = 1; x %= mod;
	while (y > 0) {
		if (y & 1)
			res = (res*x) % mod;
		y = y>>1;
		x = (x*x) % mod;
	}
	return res%mod;
}

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


Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int main(){
    string S;
    cin >> S;
    
    map<char, int> cnt;
    for(char c = 'A'; c <= 'Z'; ++c){
        cnt[c] = 0;
    }
    for(int i = 0; i < S.length(); ++i){
        cnt[S[i]]++;
    }
    for(char c = 'A'; c <= 'Z'; ++c){
        if(c == 'A'){
            if(cnt[c] > 4){
                cout << "NO\n";
                return 0;
            }
        }
        else if(c == 'K' || c == 'I' || c == 'H' || c == 'B' || c == 'R'){
            if(cnt[c] != 1){
                cout << "NO\n";
                return 0;
            }
        }
        else{
            if(cnt[c] > 0){
                cout << "NO\n";
                return 0;
            }
        }
    }
    
    int id1, id2, id3;
    id1 = S.find("KIH");
    id2 = S.find("B");
    id3 = S.find("R");
    
    if(id1 == string::npos || id2 == string::npos || id3 == string::npos){
        cout << "NO\n";
        return 0;
    }
    if(id1 > id2 || id1 > id3 || id2 > id3){
        cout << "NO\n";
        return 0;
    }
    
    if(id1 > 1){
        cout << "NO\n";
        return 0;
    }
    if(id2 - id1 > 4){
        cout << "NO\n";
        return 0;
    }
    if(id3 - id2 > 2){
        cout << "NO\n";
        return 0;
    }
    if(S.length() - id3 > 2){
        cout << "NO\n";
        return 0;
    }
    
    cout << "YES\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <map>
#include<queue>

const int INF = 1 << 28;
const long long MOD = 1000000007;
using namespace std;
using Graph = vector<vector<int>>;

template<class T> bool chmin(T &a, T &b) { if (a > b) { a = b; return 1; }return 0; }
template<class T> bool chmax(T &a, T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T, class U> using P = pair<T, U>;

vector<int> seen(50,-1);
int counter_for_dfs = 0;
void dfs(Graph &G, int v) {
	seen[v] = counter_for_dfs;
	counter_for_dfs++;
	for (auto v_next : G[v]) {
		if (seen[v_next]>=0)continue;

		dfs(G, v_next);
	}
}

void bfs(Graph &G) {
	vector<int> dist(G.size(), -1);
	queue<int> que;
	
	dist[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
		}
	}
	for (auto i : dist) {
		cout << i << " ";
	}
}

int counter[200005] = {};
void bfs2(Graph &G,int p,int x) {
	vector<int> dist(G.size() , -1);
	queue<int> que;
	
	dist[p] = 0;
	que.push(p);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
			counter[g] += x;
		}
	}
}
int main()
{
	long int n;
	std::cin >> n;
	long int reslt = (n - 1) * n / 2;
	std::cout << reslt;
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		long N = Long.parseLong(in.readLine());
		in.close();

		List<Long> list = new ArrayList<>();
		for (long i = 1; i < Math.sqrt((double) N); ++i) {
			if (N % i == 0) {
				// list.add(i);
				list.add(((N - i) / i));
			}
		}
		Collections.sort(list);
		long result = 0;
		for (Long val : list) {
			if (N % val == N / val) {
				result += val;
			}
		}

		System.out.println(result);
	}

}

Measured memory_bytes: 21588
#include<stdio.h>
int main(){
  double L,M,N,a;
  int i,b;
  while(1){
    b=0;
  scanf("%lf",&L);
  if(L==0.0)break;
  for(i=0,a=0.0;i<12;i++){
    scanf("%lf %lf",&M,&N);
    a+=(M-N);
    if(a>=L&&b==0)b=i+1;
    
  }
  if(b==0)printf("NA\n");
  else printf("%d\n",b);
  }
  return 0;
}

Measured memory_bytes: 636