akhauriyash/Code-Regression huggingface dataset:
import static java.lang.System.out;
import java.util.Scanner;
 
public class Main {
      public static void main(String...args) {
                String str = new Scanner(System.in).nextLine();
                String[] list = str.split(" ");
                String x = list[0];
                String y = list[1];
 
                int a = Integer.parseInt(x);
                int b = Integer.parseInt(y);
 
                int sum = a * b;
                int cm = (a + b) * 2;
 
                out.println(sum + " " + cm);
 
      }
 
 
}

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

int main() {
	int a[10];
	int b, c;
	while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
		&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],
		&a[7],&a[8],&a[9],&b,&c)+1) {
		int dis=0;
		for (int i = 0; i < 10; i++) {
			dis += a[i];
		}
		double disa;
		disa = static_cast<double>(dis);
		int speed = b + c;
		double x = disa / speed * b;
		int y = static_cast<int>(x);
		int j = 0;
		while (1) {
			if( y - a[j] <= 0) { break; }
			y -= a[j];
			j++;
		}
		cout << j + 1 << endl;
	}
	return 0;
}

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

int main(){
  int K;
  string N;
  
  cin >> K;
  cin >> N;
  if(N.size()>K){
  	for(int i=0; i<K; i++){
      cout << N.at(i);
    }
    cout << "..." << endl;
  }else
    cout << N << endl;
  
  return 0;
  

}




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

int main(){
    const long long int mod =1000000007;
    long int N;
    cin >> N;
    
    vector<long long int> A(N,0);
    rep(i,N) {
        cin >> A.at(i);
    }

    long long int sum1 = 0;
    long long int sum2 = 0;

    rep(i,N) {
        sum1+= A.at(i)%mod;
        sum2+= A.at(i)*A.at(i)%mod;
    }

    long long int sum = 0;
    sum = ((sum1%mod)*(sum1%mod) -sum2%mod)%mod;
    
    if(sum<0){
      sum+mod;
    }
    cout << (sum * 500000004)%mod << endl;
}

Measured memory_bytes: 4812
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio {
  int it, len;
  char s[LEN + 5];
  fastio() {
    it = len = 0;
  }
  char get() {
    if(it < len) return s[it++];
    it = 0, len = fread(s, 1, LEN, stdin);
    return len ? s[it++] : EOF;
  }
  bool notend() {
    char c;
    for (c = get();c == ' ' || c == '\n';c = get());
    if (it) it--;
    return c != EOF;
  }
  void put(char c) {
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush() {
    fwrite(s, 1, it, stdout);
  }
}buff, bufo;
inline int getint() {
  char c; int res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if(c == '-') sig = -1;
  for (;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll() {
  char c; ll res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if (c == '-') sig = -1;
  for (; c >= '0' && c <= '9'; c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char() {
  char c;
  for (c = buff.get(); c == ' ' || c == '\n'; c = buff.get());
  return c;
}
#define maxn 200005
int cnt[maxn], n, a[maxn];
ll ans;
int main() {
  n = getint();
  for (int i = 1; i <= n; i++) {
    a[i] = getint();
    ans += cnt[a[i]];
    cnt[a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    putll(ans - cnt[a[i]] + 1, '\n');
  }
  bufo.flush();
  return 0;
}


Measured memory_bytes: 3840
#include<iostream>
using namespace std;
int main()
{
	int a[200];
	int n;
	cin >> n;
	int f = 1;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		//if (a[i] == 2) { f = 0; break; }
		if (a[i]%2==0)
			if (a[i] % 3 != 0)
			{if(a[i] % 5 != 0) { f = 0; break; } }
				
	}
	if (f)cout << "APPROVED";
	else cout << "DENIED";

}

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


  
int main(){

  string s;
  cin>>s;
  
  if (s<="2019/04/30"){
    cout<<"Heisei"<<endl;
  }
  
  else {
    cout<<"TBD"<<endl;
  }
  
  

  
}
  















Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
//#define scanf scanf_s
int main()
{
	char a[100];
	int len, i;
	gets(a);
	len = strlen(a);
	for (i = 0; i <= (len - 1) / 2 / 2 - 1; i++)
	{
		if (a[i] != a[(len - 1) / 2 - 1 - i])
		{
			printf("No");
			return 0;
		}
	}
	for (i = 0; i <= (len - 1) / 2 - 1; i++)
	{
		if (a[i] != a[len-1- i])
		{
			printf("No");
			return 0;
		}
	}
	/*for (i = (len+3)/2-1; i <= ((len + 3) / 2 - 1)+(len - 1) / 2 / 2 - 1; i++)
	{
		if (a[i] != a[len-(i- (len + 3) / 2 - 1)])
		{
			printf("No");
			return 0;
		}
	}*/
	printf("Yes");
}

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

int main() {
  string S; cin >> S;
  int Q; cin >> Q;
  deque<char> q;
  for (int i = 0; i < S.size(); i++) q.push_back(S.at(i));
  int mode = 0;  // 反転しているかどうか
  for (int i = 0; i < Q; i++) {
    int com; cin >> com;
    if (com == 1) {
      mode = (mode + 1) % 2;
    }
    if (com == 2) {
      int F; cin >> F;
      char c; cin >> c;
      if (F == 1) {
        if (mode == 0) {
          q.push_front(c);
        }
        else {
          q.push_back(c);
        }
      }
      if (F == 2) {
        if (mode == 0) {
          q.push_back(c);
        }
        else {
          q.push_front(c);
        }
      }
    }
  }
  if (mode == 0) {
    while (!q.empty()) {
      cout << q.front();
      q.pop_front();
    }
  }
  else {
    while (!q.empty()) {
      cout << q.back();
      q.pop_back();
    }
  }
  cout << endl;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  vector<int> ans(N);
  rep(i,N) ans[A[i]-1]=i+1;
  rep(i,N-1) cout << ans[i] << " ";
  cout << ans[N-1] << endl;
  
  return 0;
}

Measured memory_bytes: 1536
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine().Split(' ');

        var d = new long[n];
        for (int i = 0; i < n; i++)
        {
            d[i] = long.Parse(s[i]);
        }

        var left = new long[n - 1];
        left[0] = d[0];
        for (int i = 1; i < n - 1; i++)
        {
            left[i] = left[i - 1] + d[i];
        }

        var right = new long[n - 1];
        right[n - 2] = d[n - 1];
        for (int i = n - 3; i >= 0; i--)
        {
            right[i] = right[i + 1] + d[i + 1];
        }

        var ans = long.MaxValue;
        for (int i = 0; i < n - 1; i++)
        {
            ans = Math.Min(ans, Math.Abs(left[i] - right[i]));
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 32732
import java.util.Scanner;
import java.util.Locale;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

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

    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();

    boolean flag = false;

    for (int i = 1; i <= 3; i++){
      if (A * B * i % 2 == 1) flag = true;
    }
    System.out.println(flag ? "Yes" : "No");
  }
}


Measured memory_bytes: 21588
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


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

ll a;
double b;
main() {
  file("threesum");
  ios;
  cin >> a;
  string s;
  cin >> s;
  s.erase(s.begin() + 1);
  ll b = atoll(s.c_str());
  a *= b;
  a /= 100;
  cout << a;
  return 0;
}
/**

*/


Measured memory_bytes: 3648
def hersCode(L, n):
  ok = len(L) - 1
  ng = 0
  while abs(ok - ng) > 1:
    mid = abs(ok + ng) // 2
    if L[mid] > n:
      ok = mid
    else:
      ng = mid
  return ok

def hersCode2(L, n):
  ok = 0
  ng = len(L)
  while abs(ok - ng) > 1:
    mid = abs(ok + ng) // 2
    if L[mid] < n:
      ok = mid
    elif L[mid] == n:
      if TF[mid]:
        ok = mid
      else:
        ng = mid
    else:
      ng = mid
  return ok

N = int(input())

A = list(map(int, input().split()))
A.sort()

D = [pow(2, i) for i in range(31)]
TF = [True for i in range(N + 1)]
Ans = 0
A = [-1e11] + A
for i in range(len(A) - 1, 1, -1):
  if TF[i]:
    k = D[hersCode(D, A[-1])] - A[-1]
    del A[-1]
    t = hersCode2(A, k)
    if A[t] == k:
      TF[t] = False
      Ans += 1
  else:
    del A[-1]

print(Ans)

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

using ld = long double;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    ld mx = 0.0;
    int ans1 = 100 * A + D, ans2 = D;
    for (int a = 0; a <= F; a += 100 * A) {
        for (int b = 0; a + b <= F; b += 100 * B) {
            int dissolve = (a + b) / 100 * E;
            for (int c = 0; a + b + c <= F && c <= dissolve; c += C) {
                for (int d = 0; a + b + c + d <= F && c + d <= dissolve; d += D) {
                    ld pct = (ld) (c + d) / (ld) (a + b + c + d);
                    if (pct >= mx) {
                        ans1 = a + b + c + d;
                        ans2 = c + d;
                        mx = pct;
                    }
                }
            }
        }
    }
    cout << ans1 << " " << ans2 << '\n';
}

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

using namespace std;

int main(int argc, char* argv[]) {
  long long N, C, K;
  cin >> N >> C >> K;

  vector<long long> t(N);
  for (int i = 0; i < N; ++i)
    cin >> t[i];

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

  long long ret = 1;
  long long next_lim = t[0] + K;
  long long cur_n = 1;
  for (int i = 1; i < N; ++i) {
    if (cur_n == C || t[i] > next_lim) {
      next_lim = t[i] + K;
      cur_n = 1;
      ++ret;
      continue;
    }
    ++cur_n;
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 1152
//***The night is the darkest just before the dawn***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

pair<ll,ll> p[2*100002];
ll b[2*100002];
int main()
{
	ll n,d,a,res=0,temp=0;
	cin>>n>>d>>a;

	forn(i,n){
		cin>>p[i].fi>>p[i].se;
	}

	sort(p,p+n);
	p[n].fi=p[n-1].fi+1e9;

	forn(i,n){
		p[i].se-=temp;
		if(p[i].se>0){
			ll need=(p[i].se+a-1)/a;
			temp+=(need*a);
			//cout<<need<<" ";
			res+=need;
			ll f=i,l=n;
			while(f<l){
				//cout<<"A";
				ll mid=(f+l+1)/2;
				if((p[i].fi+2*d)>=p[mid].fi) f=mid;
				else l=mid-1;
			}
			//cout<<f<<" ";
			b[f]+=(need*a);
		}
		temp-=b[i];
	}
	cout<<res;
}

Measured memory_bytes: 4992
# C - Lower

N = int(input())
H = [int(h) for h in input().split()]
cnt = []
tmp = 0
for i in range(N - 1):
    if H[i + 1] <= H[i]:
        tmp += 1
    else:
        cnt.append(tmp)
        tmp = 0
else:
    cnt.append(tmp)

print(max(cnt))


Measured memory_bytes: 14224
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

from decimal import Decimal

a, b = nas()

a = Decimal(a)
b = Decimal(b)

print(int(a * b))

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

int main(){
    int N;
    cin >> N;
    for(int i =1; i*i <= N; i++){
        if(N % i == 0 && N/i < 10){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		long[] A = new long[n];
		long[] B = new long[n];
		for(int i = 0;i < n;i++){
			A[i] = sc.nextLong();
			B[i] = sc.nextLong();
		}
		long sum[] = new long[n];
		long ans = 0l;
		for(int i = 0;i < n;i++){
			sum[i] = A[i] + B[i];
			ans -= B[i];
		}

		Arrays.sort(sum);
		for(int i = n-1;i >= 0;i -= 2){
			ans += sum[i];
		}
		
		System.out.println(ans);



	}

}



class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



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

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

  if (a*b%2 == 1) {
    cout << "Odd" << endl;
  }
  // ここにプログラムを追記
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

void solve()
{
    int a;int b;cin>>a>>b;
 	int first=500*a;
  	if(first>=b)
      cout<<"Yes"<<endl;
  	else
      cout<<"No"<<endl;
}
int32_t main()
{
    rapido;
    int t;
    // cin>>t;
    t=1;
    while(t--)
    solve();
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

string s;
ll dp[100100][13];

int main(){
	cin >> s;
	int n = s.size();
	dp[0][0]=1;
	// 桁についてループ
	for(int i = 0; i < n; i++){
		int c;
		if(s[i] == '?') c = -1;
		else c = s[i] - '0';
		// ? だった場合の全処理
		for(int j = 0; j < 10; j++){
			if (c != -1 && c != j)continue;
			
			//i-1文字目までの数が[ki]の時に，それを１０倍してjを加えた部分に
			// あまりはうつるよね？
			for(int ki = 0; ki < 13; ki++){
				dp[i+1][(ki * 10 + j) % 13] += dp[i][ki];
			}
		}
		for(int j = 0; j < 13; j++)dp[i+1][j] %= mod;
	}

	cout << dp[n][5] << endl;
	return 0;

}

Measured memory_bytes: 10624
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> v1(n/2);
  vector<int> v2(n/2);
  for(int i=0; i<n/2; i++){
    cin >> v1[i] >> v2[i];
  }
  sort(v1.begin(),v1.end());
  sort(v2.begin(),v2.end());
  int s1=1, s2=1,s1max=0, s2max=0,s12=0,s22=0,v1m=0,v2m=0;
  if(n!=2){
    for(int i=1; i<n/2; i++){
      if(v1[i]==v1[i-1]){
        s1++;
      }
      else if(v1[i]!=v1[i-1]){
        if(s1max<s1){
          s12=s1max;
          s1max=s1;
          v1m=v1[i-1];
        }
        else if(s12<s1){
          s12 = s1;
        }
        s1=1;
      }
      if(v2[i]==v2[i-1]) s2++;
      else if(v2[i]!=v2[i-1]){
        if(s2max<s2){
          s22=s2max;
          s2max=s2;
          v2m=v2[i-1];
        }
        else if(s22<s2){
          s22 = s2;
        }
        s2=1;
      }
      if(i==n/2-1){
        if(s1max<s1){
          s12=s1max;
          s1max=s1;
          v1m=v1[i-1];
        }
        else if(s12<s1){
          s12 = s1;
        }
        if(s2max<s2){
          s22=s2max;
          s2max=s2;
          v2m=v2[i-1];
        }
        else if(s22<s2){
          s22 = s2;
        }
      }
    }
  }
  if(n==2){
    if(v1[0]==v2[0]) cout << 1 << endl;
    else cout << 0 << endl;
  }
  else if(v1m==v2m && v1m != 0){
    cout << min(n-s1max-s22,n-s2max-s12) << endl;
  }
  else{
    cout << n-s1max-s2max <<endl;
  }
}


Measured memory_bytes: 640
#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<string, int>;
const int INF = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int cnt = 0;
  rep(i, n) {
    cin >> a[i];
    if (a[i] % 2 == 1 && (i + 1) % 2 == 1) cnt++;
  }
  cout << cnt << endl;
}


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

#define lli long long
#define FOR(i,a,b) for (lli i=(a);i<(b);i++)
#define REP(i,n) for (lli i=0;i<(n);i++)
#define rep(i,n) for (lli i=0;i<(n);i++)

#define INF LONG_MAX/3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(),(a),end()
#define pll pair<lli,lli>

int main(){
  int a,b,h;

  cin>>a>>b>>h;

  cout<<(a+b)*h/2<<endl;

  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PP = pair<P, P>;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int dy[] = {0, 1};
const int dx[] = {1, 0};
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    int table[h][w], used[h][w] = {};
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++) cin >> table[i][j];
    }
    vector<PP> v;
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            if(table[i][j] % 2 == 0) continue;
            for(int k = 0; k < 2; k++)
            {
                int ny = i + dy[k];
                int nx = j + dx[k];
                if(ny < 0 or nx < 0 or ny >= h or nx >= w) continue;
                table[ny][nx] += 1;
                v.push_back(PP(P(i + 1, j + 1), P(ny + 1, nx + 1)));
                break;
            }
        }
    }
    cout << v.size() << endl;
    for(int i = 0; i < v.size(); i++)
    {
        P p = v[i].first, q = v[i].second;
        cout << p.first << " " << p.second << " " << q.first << " " << q.second << endl;
    }
    return 0;
}



Measured memory_bytes: 6128
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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

bool larger_0[6];

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

  int v[6];
  REP(i,5) cin >> v[i];

  int minv = 1e9, idx = 0;
  REP(i, 5){
    int tmp = v[i]%10;
    if(tmp!=0 && tmp < minv){
      minv = tmp;
      idx = i;
    }
    if(tmp != 0){
      larger_0[i] = true;
    }
  }
  int ans=0;
  REP(i, 5){
    if(i == idx) continue;
    int tmp = v[i];
    if(larger_0[i]) tmp += 10;
    tmp -= (tmp%10);
    ans += tmp;
    //cerr << tmp << endl;
  }
  cout << ans + v[idx] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <iostream>
using namespace std;
int main ()
{
	int a,b,k;
	scanf("%i%i%i",&a,&b,&k);
	int j=1,c[99999],n=0;
	if(k+a>b)
	{
		for(int i=a;i<=b;i++)
		{
			c[j]=i;
			j++;
			n++;
		}
	}
	else
	{
		for(int i=a;i<k+a;i++)
		{
			c[j]=i;
			j++;
			n++;
		}
	}
	if(b-k<a)
	{
		for(int i=b;i>=a;i--)
		{
			c[j]=i;
			j++;
			n++;
		}
	}
	else
	{
		for(int i=b;i>b-k;i--)
		{
			c[j]=i;
			j++;
			n++;
		}
	}
	sort(c+1,c+n+1);
	for(int i=1;i<=n;i++)
	{
		if(i!=n && c[i]==c[i+1])
		{
			for(int j=i;j<n;j++)
			{
				c[j]=c[j+1];
			}
			n--;
		}
	}
	for(int i=1;i<=n;i++)
	{
		printf("%i\n",c[i]);
	}
	return 0;
}


Measured memory_bytes: 256
/***
*  author  :_shamim
*  created : 08.05.2020
*
***/

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <list>
#include <set>
#include <queue>
#include <iterator>
#include <bitset>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll             long long
#define _              ios_base::sync_with_stdio(0);cin.tie(0);
#define loop           for(i=0;i<n;i++)
#define pb             push_back
#define tc()           int t;cin>>t;while(t--)

using namespace std;

ll i,j,temp;

int main()
{_

    int x;
    vector<int > candies;
    for(i=0;i<3;i++){
        cin>>x;
        candies.pb(x);
    }

    sort(candies.begin(),candies.end());
    if((candies[0] + candies[1]) == candies[2]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-3;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int n;
ld p[3000];
//i回振ってj回表
ld dp[3000][3000];
int main() {
	cout << fixed << setprecision(10);
	cin >> n; rep(i, n)cin >> p[i];
	dp[0][0] = 1;
	rep(i, n) {
		rep(j, i + 1) {
			dp[i + 1][j] += dp[i][j] * (1 - p[i]);
			dp[i + 1][j + 1] += dp[i][j] * p[i];
		}
	}
	ld ans = 0;
	rep(i, n + 1) {
		if (i > n / 2)ans += dp[n][i];
	}
	cout << ans << endl;
	//stop
	return 0;
}

Measured memory_bytes: 139136
#include<stdio.h>

int main(void){
  
  char str[11];
  int i,result = 0,lenth_long = 0;
  
  scanf("%s",str);
  
  for(i = 0;str[i] != '\0';i++){
    if(str[i] == 'A' || str[i] == 'C' || str[i] == 'G' || str[i] == 'T'){
      lenth_long++;
    }else{
      if(result < lenth_long){
        result = lenth_long;
      }
      lenth_long = 0;
    }
  }
    
  if(result < lenth_long){
    result = lenth_long;
  }
  
  printf("%d",result);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
	int N;
	int num[100];
	int key;
	
	int mini;
	int count = 0;
	
	int i,j;
	
	scanf("%d",&N);
	
	for(i = 1;i <= N;i++){
		scanf("%d",&num[i]);
	}
	
	for(i = 1;i <= N;i++){
		mini = i;
		for(j = i;j <= N;j++){
			if(num[j] < num[mini]){
				mini = j;
			}
		}
		if(num[i] != num[mini])count++;
		key = num[i];
		num[i] = num[mini];
		num[mini] = key;
	}
	
	for(i = 1;i <= N;i++){
		printf("%d",num[i]);
		if(i < N){
			printf(" ");
		}
	}
	printf("\n");
	printf("%d\n",count);
		
		
return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  
  for (int i = 0; i < N; i++){
    cin >> v.at(i);
  }
  
  sort(v.begin() , v.end());
  
  cout << v.at(N/2) - v.at(N/2 - 1) << endl;
  
}
  
  
  

Measured memory_bytes: 640
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
#include <iomanip>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int dfs(vector<int> &A, vector<int> &B, int n) {
  if (n == A.size()) {
    int ok = 0;
    for(int i = 0; i < B.size(); i++) {
      if (B[i] % 2 == 0) ok = 1;
    }
    return ok;
  }
  int ret = 0;
  B[n] = A[n] - 1; ret += dfs(A, B, n + 1);
  B[n] = A[n] + 0; ret += dfs(A, B, n + 1);
  B[n] = A[n] + 1; ret += dfs(A, B, n + 1);
  return ret;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<int> B(N);
  cout << dfs(A, B, 0) << endl;
  return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

// 最大公約数
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int N,M;
string S,T;
signed main() {
    cin >> N >> M>>S>>T;
    int g=gcd(N,M);
    for(int i=0;i<g;i++){
        if(S[N/g*i]!=T[M/g*i]){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<N*M/g<<endl;
}


Measured memory_bytes: 512
#include <stdio.h>
 
int main(void){

    double a,b,c;

    scanf("%lf %lf %lf",&a,&b,&c);
    c=c*3.14159265/180.0;

    printf("%f\n",a*b*sin(c)/2);
    printf("%f\n",a+b+sqrt(a*a+b*b-2*a*b*cos(c)));
    printf("%f\n",b*sin(c));

    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  cout<<180*(n-2)<<endl;
  
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
using namespace std;

int main(void){
  int n,m,a,b;
    cin >> n >> m;
    vector<pair<int, int > > x, y;
    for (int i= 0; i < n; i++){
      cin >> a >> b;
      x.push_back(pair<int, int>(a, b));
    }
    for (int i= 0; i < m; i++){
      cin >> a >> b;
      y.push_back(pair<int, int>(a, b));
    }

    for (int i = 0; i < n; i++) {
      int min_d = abs(x[i].first-y[0].first) + abs(x[i].second-y[0].second);
      int res = 1;
      for(int j = 1; j < m; j++){
	int d = abs(x[i].first-y[j].first) + abs(x[i].second-y[j].second);
	if (min_d > d) {
	  res = j + 1;
	  min_d = d;
	}
      }
      cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define M 1000000/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return (key % M) % M; }
int h2(int key){ return (1 + key % (M - 1)); }

int find(char str[]){
  long long key,n,i; 
  key = getKey(str);
  for(i = 0; i < M; i++){
    n = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[n],str) == 0) return 1;
    else if(strlen(H[n]) == 0)return 0;
  }
}

  int insert(char str[]){
    long long key,n,i; 
    key = getKey(str);
    for(i = 0; i < M; i++){
      n = (h1(key) + i * h2(key)) % M;
      if(strcmp(H[n],str) == 0) break;
      else if(strlen(H[n]) == 0){
	strcpy(H[n],str);
	break;
      }
    }
  }
 
  int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
      scanf("%s %s", com, str);
	
      if ( com[0] == 'i' ){
	insert(str);
      } else {
	if (find(str)){
	  printf("yes\n");
	} else {
	  printf("no\n");
	}
      }
    }

    return 0;
  }



Measured memory_bytes: 15404
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;
vector<map<ll,ll>>dp;
ll n,m;
vector<vector<ll>> edge;
vector<ll>lmul,rmul;
ll dfs0(ll par,ll node)
{
  if(dp[node].count(par))return dp[node][par];
  ll res=1;
  for(auto nn:edge[node])
  {
    if(nn==par)continue;
    res=(ll)res*(dfs0(node,nn)+1)%m;
  }
  dp[node][par]=res;
  return res;
}
ll dfs(ll par,ll node)
{
  //cout<<par<<" "<<node<<endl;
  if(dp[node].count(par))return dp[node][par];
  if(edge[node].size()==1&&par!=-1)return 1;
  ll mul=1;
  vector<ll>lmul(edge[node].size()),rmul(edge[node].size());
  lmul.assign(edge[node].size(),0);
  rmul.assign(edge[node].size(),0);
  for(auto itr=edge[node].begin();itr!=edge[node].end();itr++)
  {
    int idx=itr-edge[node].begin();
    lmul[idx]=mul;
    mul=mul*(dfs(node,*itr)+1)%m;
  }
  mul=1;
  for(auto itr=edge[node].rbegin();itr!=edge[node].rend();itr++)
  {
    int idx=edge[node].rend()-itr-1;
    rmul[idx]=mul;
    mul=mul*(dfs(node,*itr)+1)%m;
  }
  for(auto itr=edge[node].begin();itr!=edge[node].end();itr++)
  {
    int idx=itr-edge[node].begin();
    dp[node][*itr]=lmul[idx]*rmul[idx]%m;
  }
  dp[node][-1]=mul;
  return dp[node][par];
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>n>>m;
  edge.resize(n);
  dp.resize(n);
  rep(i,n-1)
  {
    ll a,b;
    cin>>a>>b;
    a--;b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  dfs0(-1,0);
  rep(i,n)
  {
    cout<<dfs(-1,i)<<"\n";
  }
  cout<<flush;
  return 0;

}


Measured memory_bytes: 38528
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <list>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
// const ll MOD = 1000000009;

#define M 1000000007

int main() {
    ll n;
    cin >> n;
    ll count = 0;
    vector<vector<ll>> vals(10, vector<ll>(10, 0));
    for (ll i = 1; i <= n; ++i) {
        ll top, bottom;
        bottom = i % 10;
        top = i;
        while (top >= 10) {
            top /= 10;
        }
        vals[top][bottom]++;
    }
    ll ans = 0;
    for (ll i = 1; i < 10; ++i) {
        for (ll j = 1; j < 10; ++j) {
            ans += vals[i][j] * vals[j][i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError("n is int type.")
    if n < 2:
        raise ValueError("n is more than 2")
    prime = [2]
    limit = int(n ** 0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


def main():
    Q = int(input())
    LR = [list(map(int, input().split())) for _ in range(Q)]
    N = 10 ** 5

    primes = get_sieve_of_eratosthenes(N)

    t = [0 for _ in range(N + 1)]
    for p in primes:
        a, b = divmod(p + 1, 2)
        if b == 0 and a in primes:
            for i in range(p, N + 1):
                t[i] += 1

    for l, r in LR:
        print(t[r+1] - t[l-1])


main()



Measured memory_bytes: 97324
program b177

implicit none
character(len=1000) :: s, t
integer(16) :: i, m, n, max, j, count

read *, s
read*,  t

do i = 1, 1000
 if(t(i:i) == ' ') then
  n = i - 1
  exit
 else
  n = 1000
 end if
end do

do i = 1, 1000
 if(s(i:i) == ' ') then
  m = i - 1
  exit
 else
  m = 1000
 end if
end do

max =  0
count = 0


do i = 1, m-n+1
 do j = 1, n
  if(s(i-1+j:i-1+j) == t(j:j)) then
   count = count + 1
  end if
 end do
 
 !print *, count
 
 if(count > max) then
  max = count
 end if
 
 count = 0
 
end do

print *, n - max


end program b177

Measured memory_bytes: 2816
#include <iostream>
using namespace std;
int main(void){
  long long N;
  cin >> N;
  
  long long ans = 0;
  
  for(int X=1;X<=N;X++){
    long long Y = N / X;
    long long G = Y * (Y + 1) * X / 2;
    ans += G;
  }
  
  cout << ans << endl;
  
  return 0;
}


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

int main()
{
    int n;

    while(cin>>n)
    {
        int a[n],b[n],counter=1,res=0;

        memset(b,0,sizeof(b));

        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        for(int i=1;i<n;i++)
        {
            if(a[i-1]==a[i])
            {
                counter++;
            }
            else
            {
                res=res+(counter/2);
                counter=1;
            }
        }
        cout<<res+(counter/2)<<endl;
    }

    return 0;
}


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

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int m=0,n=0;
	if (a%d==0) m=a/d;
	 else m=a/d+1;
	if (c%b==0) n=c/b;
	 else n=c/b+1;
	 
	if( m< n)	cout<<"No"<<endl;
	
	else cout<<"Yes"<<endl;	
	
	return 0;
} 

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n,x;cin >> n >> x;
    vector<int> a(n);rep(i,n)cin >> a[i];
    ll ans = 0;
    rep(i,n-1)
    {
        if(a[i]+a[i+1]>x)
        {
            ans += (a[i] + a[i + 1]-x);
            if(x-a[i]<0)
            {
                a[i+1] = 0;
            }else
            {
                a[i + 1] = x - a[i];
            }
        }
    }
    cout << ans << endl;

}

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

int main(){
  int n, k; cin >> n >> k;
  vector<int> l(n);
  for(int i=0; i<n; i++){
    cin >> l.at(i);
  }
  
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  int ans = 0;
  for(int i=0;i<k;i++){
    ans += l.at(i);
  }
  
  cout << ans << endl;

}  

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<string>
#include<algorithm>
using namespace std;
int max(int a,int b){return a>b?a:b;}
int main(){
	int n;
	scanf("%d",&n);
	for(int d=0;d<n;d++){
		char a[10000];
		char b[10000];
		scanf(" %s",a);
		scanf(" %s",b);        
		if(strlen(a) > 80 || strlen(b) > 80) {
            printf("overflow\n");
            continue;
        }
		string s,t;
		int i=0;
		s.append(a);
		t.append(b);
		reverse(s.begin(),s.end());
		reverse(t.begin(),t.end());
		string ans;
		int k=0;
		for(i=0;i<max(s.size(),t.size())+1;i++){
			int x,y;
			if(i>=s.size())x=0;
			else x=s[i]-'0';
			if(i>=t.size())y=0;
			else y=t[i]-'0';
			int z=x+y+k;
			k=z/10;
			char c=z%10+'0';
			if(i!=max(s.size(),t.size())||c!='0')ans.append(1,c);
		}
		reverse(ans.begin(),ans.end());
		if(ans.size()>=81)printf("overflow\n");
		else printf("%s\n",ans.c_str());
	}
	return 0;
}

Measured memory_bytes: 1056
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n+1]; for (int i = 0; i <= n; i++) cin >> a[i];
    long long s[n+1];
    s[n] = 0;
    for (int i = n-1; i >= 0; i--) s[i] = s[i+1] + a[i+1];
    long long t = 1;
    long long ans = 0;
    for (int i = 0; i <= n; i++) {
        // cerr << "level " << i << " " << t << " nodes " << a[i] << " leaves "
        //      << s[i] << " nodes required " << ans << endl;
        ans += t;
        t -= a[i];
        t *= 2;
        if (t > s[i]) t = s[i];
        if (t < 0) {
            cout << "-1\n";
            return 0;
        }
    }
    cout << ans << endl;    
}


Measured memory_bytes: 4804
S = (input())						# 5
K = int(input())						# 5

## 5000兆日
#a = 5000 * 10000 * 10000 * 10000
#
## 10の18乗
#k = 10 ** 18 = 10 * 1000 * 1000 * 1000 * 1000 * 1000 * 1000


iLen = len(S)
iMin = min(iLen, K)

ans="1"
for i in range(iMin):
	c = S[i]
	if (c=="1"): continue
	ans = c
	break

print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
	int n, k, i, d, a, j, ans;
	bool h[103] = { false };

	scanf("%d%d", &n, &k);
	for (i = 0; i < k; i++) {
		scanf("%d", &d);
		for (j = 0; j < d; j++) {
			scanf("%d", &a);
			h[a - 1] = true;
		}
	}

	ans = 0;
	for (i = 0; i < n; i++) {
		if (!h[i]) {
			ans++;
		}
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 3828
#include<stdio.h>
#define INF 1000000
void warshall_floyd(void);
int min(int,int);
int graph[101][101],n,c,d;

int main(void){
  int k,i,j,x,e,a,b;

  while(scanf("%d %d",&n,&k),n,k){

    for(i=0;i<=n;i++)
      for(j=0;j<=n;j++)
	graph[i][j]=(i==j?0:INF);

    for(i=0;i<k;i++){

      if(scanf("%d",&x),x){
	scanf("%d %d %d",&c,&d,&e);
	if(graph[c][d]>e){
	graph[c][d]=graph[d][c]=e;
	warshall_floyd();
	}
      }
      else{
	scanf("%d %d",&a,&b);
	if(graph[a][b]<INF)printf("%d\n",graph[a][b]);
	else printf("-1\n");
      }
    }
  }
  return 0;
}

void warshall_floyd(void){
  int i,j;
  
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][c]+graph[c][d]+graph[d][j]);
    }
  }
}

int min(int x,int y){
  return (x<y)?x:y;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  int ans=0;
  while(1){
    int count=0;
    vi B(N);
    rep(i,0,N){
      count+=A[i]/N;
      B[i]=A[i]/N;
      A[i]%=N;
    }
    rep(i,0,N){
      A[i]+=count;
      A[i]-=B[i];
      }
    if(count==0){
      cout<<ans<<endl;
      break;
    }
    ans+=count;
  }
  }



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const  ll INF = 1e18;
const  ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i<(n);i++)
#define repd(i,n,init) for(ll i=(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define repb(bit,n,init) for(ll bit=init;bit<(1<<n);++bit)

int main()
{
    ll a,b,c;
    cin >> a >> b >> c;
    cout << (a+b == c || b+c == a || c + a == b ? "Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    X, N = map(int, input().split())
    p = list(map(int, input().split()))

    nums = [i for i in range(-200, 200)]

    for i in range(N):
        nums.remove(p[i])
        
    min_diff = 1000
    min_index = 1000

    for i in range(len(nums)):
        if abs(X - nums[i]) < min_diff or (abs(X - nums[i]) == min_diff and nums[min_index] > nums[i]):
            min_diff = abs(X-nums[i])
            min_index = i

    print(nums[min_index])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int res = 700;
  if (S[0] == 'o') res += 100;
  if (S[1] == 'o') res += 100;
  if (S[2] == 'o') res += 100;
  cout << res << endl;
}

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

int main(){
  int n,a[1000];
  while(1){
    cin>>n;
    if(n==0) break;
    for(int i=0;i<n;i++) cin>>a[i];
    int sum=0;
    for(int i=0;i<n;i++) sum +=a[i];
    double avg=1.0*sum/n;
    double dist=0.0;
    for(int i=0;i<n;i++){
      dist +=(avg-a[i])*(avg-a[i]);
    }
    printf("%lf\n",sqrt(dist/n));
  }
    
  return 0;
}
    



Measured memory_bytes: 3192