akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
const int N = 1000010;
using namespace std;
int main()
{
 
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
     //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n,s = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        if(i%3 != 0)
        {
            if( i%5 != 0)
                s += i;
        }
    }
    cout << s;
    return 0;
} 

Measured memory_bytes: 3676
import java.util.*;
import javax.lang.model.util.ElementScanner6;

public class Main {

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

        // 入力
        int n = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        int v;
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            if (map.get(s) == null) {
                map.put(s, 1);
            } else {
                v = map.get(s);
                map.put(s, v + 1);
            }
        }

        // 処理
        // 値の最大値を求める
        int max = 0;
        Iterator<Integer> vals = map.values().iterator();
        while (vals.hasNext()) {
            int val = vals.next();
            if (val > max) {
                max = val;
            }
        }
        // 値が最大値のものを出力する
        List<String> list = new ArrayList();
        Iterator<Map.Entry<String, Integer>> imap = map.entrySet().iterator();
        while (imap.hasNext()) {
            Map.Entry<String, Integer> entry = imap.next();
            if (entry.getValue() == max) {
                list.add(entry.getKey());
            }
        }

        Collections.sort(list);
        for (String e : list) {
            System.out.println(e);
        }

        // 出力
        // System.out.println(map);
    }

}

Measured memory_bytes: 81632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
ll n;
map<string, ll> mp;
cin>>n;
for (ll i = 0; i < n;i++){
    string t;
    cin >> t;
    mp[t]++;
}
cout << "AC x " << mp["AC"] << endl;
cout << "WA x " << mp["WA"] << endl;
cout << "TLE x " << mp["TLE"] << endl;
cout << "RE x " << mp["RE"] << endl;


}

Measured memory_bytes: 3600
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    string s=to_string(n);
    int hoge=0;
    for(int i=0;i<s.size();i++) hoge+=s.at(i)-'0';
    
    if(n%hoge==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "stdc++.h"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = max(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

	int N, min_value;
	int cnt = 1;
	cin >> N;
	cin >> min_value;
	rep(i, N - 1) {
		int a;
		cin >> a;
		if (a <= min_value) {
			min_value = a;
			cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static class Point {
        public double x, y;

        public Point(double x, double y) {
            this.x = x;
            this.y = y;
        }
    }

    public static void koch(int n, Point a, Point b) {
        if (n == 0) return;

        double th = Math.PI * 60.0 / 180.0;  // 将单位从度变为弧度

        double s_x = (2.0 * a.x + 1.0 * b.x) / 3.0;
        double s_y = (2.0 * a.y + 1.0 * b.y) / 3.0;
        double t_x = (1.0 * a.x + 2.0 * b.x) / 3.0;
        double t_y = (1.0 * a.y + 2.0 * b.y) / 3.0;
        double u_x = (t_x - s_x) * Math.cos(th) - (t_y - s_y) * Math.sin(th) + s_x;
        double u_y = (t_x - s_x) * Math.sin(th) + (t_y - s_y) * Math.cos(th) + s_y;

        Point s = new Point(s_x, s_y);
        Point t = new Point(t_x, t_y);
        Point u = new Point(u_x, u_y);

        koch(n - 1, a, s);
        System.out.println(String.format("%.8f %.8f", s.x, s.y));
        koch(n - 1, s, u);
        System.out.println(String.format("%.8f %.8f", u.x, u.y));
        koch(n - 1, u, t);
        System.out.println(String.format("%.8f %.8f", t.x, t.y));
        koch(n - 1, t, b);
    }

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

        Point a = new Point(0.0, 0.0);
        Point b = new Point(100.0, 0.0);
        
        System.out.println(String.format("%.8f %.8f", a.x, a.y));
        koch(n, a, b);
        System.out.println(String.format("%.8f %.8f", b.x, b.y));
    }
}



Measured memory_bytes: 40196
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, i; cin >> N; int a[N];
for(i=0; i<N; i++){ cin >> a[i]; }
if(N%2){
for(i=N-1; i>=0; i-=2){ cout << a[i] << " "; }
for(i=1; i<N; i+=2){ cout << a[i] << " "; }
}else{
for(i=N-1; i>=1; i-=2){ cout << a[i] << " "; }
for(i=0; i<N; i+=2){ cout << a[i] << " "; } 
}
cout << "\n";
}

Measured memory_bytes: 2944
# include <bits/stdc++.h>
    using namespace std;
     
    typedef long long LL;
    const int N = 2003;
    char s[N][N];
    int l[N][N]={0}, r[N][N]={0}, o[N][N]={0};
    int main()
    {
        int n, m, q, a, b, c, d, A, B, C, D;
        scanf("%d%d%d",&n,&m,&q);
        for(int i=1; i<=n; ++i)
            scanf("%s",s[i]+1);
        for(int i=1; i<=n; ++i)
        {
            for(int j=1; j<=m; ++j)
            {
                l[i][j] = l[i][j-1] + l[i-1][j] - l[i-1][j-1];
                o[i][j] = o[i][j-1] + o[i-1][j] - o[i-1][j-1];
                r[j][i] = r[j][i-1] + r[j-1][i] - r[j-1][i-1];
                if(s[i][j]=='1')
                {
                    ++o[i][j];
                    if(s[i][j-1] == '1') ++l[i][j];
                    if(s[i-1][j] == '1') ++r[j][i];
                }
            }
        }
        while(q--)
        {
            scanf("%d%d%d%d",&A,&B,&C,&D);
            a = min(A, C);
            b = min(B, D);
            c = max(A, C);
            d = max(B, D);
            int cnt, line;
            cnt = o[c][d] - o[c][b-1] - o[a-1][d] + o[a-1][b-1];
            line = l[c][d] - l[c][b] - l[a-1][d] + l[a-1][b];
            line += r[d][c] - r[b-1][c] - r[d][a] + r[b-1][a];
            printf("%d\n",cnt-line);
        }
        return 0;
    }

Measured memory_bytes: 52736
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> 
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }


int N; ll X;

ll rec(int n, ll x) {
  if (n==0) return 1;
  if (x==1) return 0;

  ll bp = (1LL<<(n+1)) - 3;
  ll p = (1LL<<(n)) - 1;
  if (x <= bp + 1) return rec(n-1, x-1);
  if (x == bp + 2) return p + 1;
  if (x <= (bp+1) * 2) return p + 1 + rec(n-1, x-bp-2);
  return p * 2 + 1;
}

void solve() {
  cin >> N >> X;
  cout << rec(N, X) << endl;
}
int main() {
 
  solve();

  return 0;
}


Measured memory_bytes: 256
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val s = in.readLine().reverse

    val candidates = List("dream", "dreamer", "erase", "eraser").map(_.reverse)

    @tailrec
    def isMatch(s: String): Boolean = {
      if (s == "") {
        true
      } else {
        candidates.find(s.startsWith) match {
          case Some(c) => isMatch(s.substring(c.length))
          case None => false
        }
      }
    }

    out.println(
      if (isMatch(s)) {
        "YES"
      } else {
        "NO"
      }
    )
    out.flush()
  }
}


Measured memory_bytes: 115580
#include<bits/stdc++.h>
using namespace std; 
using lint =                            long long int;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD 1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){
  int H;
  cin>>H;
  int N;
  cin>>N;
  vector<int> a(N);
  cin>>a;

   cout<< (accumulate(ALL(a),0LL) >= H ? "Yes" : "No" )<< endl;

}

int main(){   
  
 solve();

 return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;

using namespace std;
const ll INF = 1000000000;
ll n, a, b;
ll num[100005];
bool pan(ll x)
{
    ll sum = 0;
    FOR(i,1,n)
    {
        ll s = num[i]-b*x;
        if(s > 0)
        {
            if(s%(a-b) == 0)sum += s/(a-b);
            else sum += s/(a-b)+1;
        }
    }
    if(sum > x)return true;
    else return false;
}
bool pan2(ll x)
{
    ll sum = 0;
    FOR(i,1,n)
    {
        ll s = num[i]-b*x;
        if(s > 0)
        {
            if(s%(a-b) == 0)sum += s/(a-b);
            else sum += s/(a-b)+1;
        }
    }
    if(sum <= x)return true;
    else return false;
}
int main()
{
    ll sum = 0;
    cin >> n >> a >> b;
    FOR(i,1,n){cin >> num[i];sum += num[i];}
    sort(num+1, num+n+1);
    ll l = 1, r = INF;
    while(l+1 < r)
    {
//        cout << l << ' ' << r << endl;
        ll m = (l+r)/2;
        if(pan(m))l = m;
        else r = m;

    }
    if(pan2(r-1) && l == 1)
    {
        r--;
    }
    cout << r << endl;
    return 0;
}


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

int main(void){
  int X, N; cin >> X >> N;
  int res, min = 100100100;
  int v[110]={0};

  rep(i,N){
    int p; cin >> p;
    v[p] = 1;
  }
  if(v[X]==0){
    cout << X << endl;
    return 0;
  }
  int a = X-1, b = X+1;
  rep(i,100){
    if(v[a] == 0){
      res = a;
      break;
    } else if(v[b] == 0){
      res = b;
      break;
    }
    if(a>0) a--;
    if(b<=101) b++;
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;

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

    vector<long long> f(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j += i) {
            f[j]++;
        }
    }

    long long res = 0;
    for (int i = 1; i <= n; i++) {
        res += i * f[i];
    }

    cout << res << endl;
}


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

using namespace std;

int main() {
   int a,b;
   cin >> a >> b;
   if(a==1) a=14;
   if(b==1) b=14;
   cout << (a>b ? "Alice" : a<b ? "Bob" : "Draw") << endl;
 }

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      aa: [u64; n],
    }
    let mut b = aa.clone();
    b.sort();
    let mut ans = 0;
    for i in 0..n {
        let idx = b.binary_search(&aa[i]).unwrap();
        if i%2 == 0 && idx%2==1 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
L,R = map(int,input().split())

diff = R - L
diff = min(diff,2019)

ans = 2019

for l in range(L,L+diff):
    for r in range(l+1,l+diff+1):
        if r > R or l > R:
            break
        ans = min(ans,(l*r)%2019)
print(ans)



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

int a,b,c;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	if(b-a+1>c*2){
	for(int i=0;i<c;i++){
	printf("%d\n",a+i);
	}
	for(int i=0;i<c;i++){
	printf("%d\n",b-c+i+1);
	}
	}else{
	for(int i=a;i<=b;i++){
	printf("%d\n",i);
	}
	}
/*
for(int i=1;i<=x;i++){
	ans++;
	plus+=i;
	if(plus>=x)break;
}
printf("%d\n",ans);
*/
	
//	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<double,int> pint;
typedef long long ll;
const int inf   = 1<<29;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  string s,t;
  cin>>s>>t;
  reverse(s.begin(),s.end());
  if(s==t)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
  } 


Measured memory_bytes: 256
# 数値を取得
word_list = input().split()
w_cnt = len(word_list)

# 語頭語尾の抽出
s_list = []
e_list = []
for cnt in range(0,w_cnt,1):
    s_list.append(word_list[cnt][0])
    e_list.append(word_list[cnt][-1])

# 成立してるか検査後結果を出力
judge = "YES"
for cnt in range(1,w_cnt,1):
    if s_list[cnt] != e_list[cnt-1]:
        judge = "NO"
print(judge)

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

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define REV(i, a) for (int i = (a); i >= 0; --i)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) cerr << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N;
int S[105];

signed main() {
    cin >> N;

    int sum = 0;
    REP(i, N) {
        cin >> S[i];
        sum += S[i];
    }
    sort(S, S + N);

    REP(i, N) {
        if (sum % 10 != 0) break;
        if (S[i] % 10 == 0) continue;
        sum -= S[i];
    }
    if (sum % 10 == 0) sum = 0;
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
       public static void main(String[] args){
              Scanner sc = new Scanner(System.in);
            
              int a = sc.nextInt();
              int second = a%60;
              int minute = a/60;
              int hour = minute / 60;
              minute = minute % 60;
              
              System.out.println(hour + ":" + minute + ":" + second );
       }
}

Measured memory_bytes: 26188
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var k = 0;
        for (int a = 1; a < n; ++a)
        {
            k += (n - 1) / a;
        }

        Console.WriteLine(k);
    }
}


Measured memory_bytes: 27424
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        Map<Integer,Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            map.put(A[i],map.getOrDefault(A[i],0)+1);
        }

        int ans = 0;
        for (int i = 0; i < N; i++) {
            int tmp = A[i];
            List<Pair> primes = new ArrayList<>();
            for (int p = 2; p*p <= tmp; p++) {
                if (tmp%p != 0) continue;

                Pair pair = new Pair(p);
                while (tmp%p == 0) {
                    pair.cnt++;
                    tmp /= p;
                }
                primes.add(pair);
            }
            if (tmp != 1) primes.add(new Pair(tmp,1));
            map.put(A[i],map.get(A[i])-1);
            boolean found = find(primes, map, 0, 1);
            if (!found) {
                ans++;
            }
            map.put(A[i],map.get(A[i])+1);
        }

        System.out.println(ans);
    }

    private static boolean find(List<Pair> primes, Map<Integer,Integer> map, int now, int div) {

        if (now == primes.size()) {
            return map.get(div) != null && map.get(div) > 0;
        }

        Pair a = primes.get(now);
        int tmp = 1;
        boolean ret = false;
        for (int i = 0; i <= a.cnt; i++) {
            ret |= find(primes, map, now+1, div*tmp);
            tmp *= a.p;
        }
        return ret;
    }

    private static class Pair {
        final int p;
        int cnt;
        Pair(int p) {
            this.p = p;
            this.cnt = 0;
        }
        Pair(int p, int cnt) {
            this.p = p;
            this.cnt = cnt;
        }
    }
}


Measured memory_bytes: 76556
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC60(void);
void ABC61(void);
void ABC62(void);
void ABC63(void);
void ABC64(void);
void ABC65(void);
void ABC66(void);
void ABC67(void);
void ABC68(void);
void ABC69(void);

int main(void){
    ABC63();
}

void ABC63(){
    int ans=1;
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    for(int i=0;i<s.length()-1;i++){
        if(s[i]==s[i+1])ans=0;
    }
    if(ans)cout<<"yes"<<endl;
    else cout<<"no"<<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 allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(b))

int T;
int m, n;

void solve() {
	int s = m * m + n * n;	
	int range = ceil(sqrt(s));
	
	int cnt = 0;
	for_(i,-range,range + 1) for_(j,-range,range + 1) {
		if (i == 0 && j == 0) continue;
		int div = i * i + j * j;
		int mul1 = i * m + j * n, mul2 = i * n - j * m;
		
		if (mul1 % div == 0 && mul2 % div == 0) cnt++;
	}
	
	cout << ( (cnt == 8) ? "P" : "C") << endl;
}

int main() {
	cin >> T;
	for_(i,0,T) {
		cin >> m >> n;
		solve();
	}
	return 0;
}

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

using namespace std;

const int maxn = 200005;

typedef pair<int,int> pi;

map<pi,int> sav;
int fa[maxn],f1[maxn],n,k,l;

int get(int *a,int p)
{
	return a[p] == p ? p : a[p] = get(a,a[p]);
}

int main()
{
	scanf("%d%d%d", &n, &k, &l);
	for(int i = 1;i <= n;i ++) fa[i] = f1[i] = i;
	for(int i = 1;i <= k;i ++)
	{
		int u,v;
		scanf("%d%d", &u, &v);
		fa[get(fa,u)] = get(fa,v);
	}
	for(int i = 1;i <= l;i ++)
	{
		int u,v;
		scanf("%d%d", &u, &v);
		f1[get(f1,u)] = get(f1,v);
	}
	for(int i = 1;i <= n;i ++)
		sav[pi(get(fa,i),get(f1,i))] ++;
	for(int i = 1;i <= n;i ++)
		printf("%d%c",sav[pi(get(fa,i),get(f1,i))],i == n ? '\n' : ' ');
	return 0;
}


Measured memory_bytes: 13568
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;



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

	cin >> N;
	for (int i = 105; i <= N; i += 2) {
		int cnt = 0;
		for (int j = 1; j <= i; j++) {
			if (i%j == 0)cnt++;
		}
		if (cnt == 8)M++;
	}
	cout << M << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }



void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    
    int ans = 0;
    rep(l, k + 1) rep(r, k - l + 1) { // 個数
        if (l + r > n) continue;
        
        priority_queue<int, vector<int>, greater<int> > q;
        rep(i, l) q.push(v[i]);
        rep3(i, n - r, n) q.push(v[i]);
        
        int d = k - l - r;
        rep(i, d) {
            if (sz(q) && q.top() <= 0) q.pop();
            else break;
        }
        
        int sum = 0;
        while (!q.empty()) {
            sum += q.top();
            q.pop();
        }
        chmax(ans, sum);
    }
    cout << ans << endl;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}




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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;



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

	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, n) cin >> p[i];

	int ans = 0;

	for (int i = 1; i < n - 1; i++) {
		int fi = p[i - 1];
		int se = p[i];
		int th = p[i + 1];
		if ((fi < se && se < th) || (fi > se && se > th)) {
			ans++;
		}
	}

	out(ans);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll x,result=0;
  ld m=1;
  scanf("%lld",&x);
  while(100*m<x){
    m *= 1.01;
    m = floorl(m*100)/100;
    result++;
  }
  printf("%lld",result);
  return 0;
}



Measured memory_bytes: 1732
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

N = int(input())
a = tuple(map(int,input().split()))
tmp = [0]
for i in range(1,N):
    tmp.append(2*a[i-1] - tmp[i-1])
res = [abs(tmp[N-1]//2 - a[N-1])]
for i in range(1,N):
    res.append(2*a[i-1]-res[i-1])
print(' '.join([str(res[i]) for i in range(N)]))


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

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);
        long[] sum = new long[n + 1];
        for (int i = 0 ; i < n ; i++) {
            sum[i + 1] += (long) a[i] + sum[i];
        }

        int count = 0;
        for (int i = 1 ; i < n ; i++) {
            if (a[i] > sum[i] * 2) count = i;
        }

        System.out.println(n -  count);
    }

}

Measured memory_bytes: 50084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n;
    cin>>n;

    ll k=1;
    n+=1;
    while(n--&&k==1){
        for(ll i=1; i*i<=n; i++){
            if(i*i==n){
                cout<<n<<endl;
                k=0;
                break;
            }
        }

    }

}


Measured memory_bytes: 3556
#include<iostream>
#include<cmath>
#include<cstdio>
#define eps (1e-11)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){return Point(x+p.x,y+p.y);}
  Point operator-(Point p){return Point(x-p.x,y-p.y);}
  Point operator*(double k){return Point(x*k,y*k);}
  Point operator/(double k){return Point(x/k,y/k);}

  double abs(){return sqrt(norm());}
  double norm(){return (x*x+y*y);}
};
typedef Point Vector;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1,Point p2):p1(p1),p2(p2){}
};
typedef Segment Line;

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

Point project(Segment s,Point p){
  Vector base=(s.p2-s.p1);
  double r=(dot(p-s.p1,base)/base.norm());
  return (s.p1+base*r);
}

Point reflect(Segment s,Point p){
  return p+(project(s,p)-p)*2;
}

bool isOrthogonal(Vector a,Vector b){
  return equals(dot(a,b),0.0);
}

bool isParallel(Vector a,Vector b){
  return equals(cross(a,b),0.0);
}

static const int COUNTER_CLOCKWISE=1;
static const int CLOCKWISE=-1;
static const int ONLINE_BACK=2;
static const int ONLINE_FRONT=-2;
static const int ON_SEGMENT=0;

int ccw(Point p0,Point p1,Point p2){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if(cross(a,b)>eps)return COUNTER_CLOCKWISE;
  if(cross(a,b)<-eps)return CLOCKWISE;
  if(dot(a,b)<-eps)return ONLINE_BACK;
  if(a.norm()<b.norm())return ONLINE_FRONT;
  return ON_SEGMENT;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
  return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 &&
          ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

bool intersect(Segment s1,Segment s2){
  return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

Point getCrossPoint(Segment s1,Segment s2){
  Vector base=s2.p2-s2.p1;
  double d1=abs(cross(base,s1.p1-s2.p1));
  double d2=abs(cross(base,s1.p2-s2.p1));
  double t=d1/(d1+d2);
  return (s1.p1+(s1.p2-s1.p1)*t);
}

double getDistanceLP(Line l,Point p){
  return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}

double getDistanceSP(Segment s,Point p){
  if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
  if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
  return getDistanceLP(s,p);
}

double getDistance(Segment s1,Segment s2){
  if(intersect(s1,s2))return 0.0;
  return min(min(getDistanceSP(s1,s2.p1),getDistanceSP(s1,s2.p2)),
             min(getDistanceSP(s2,s1.p1),getDistanceSP(s2,s1.p2)));
}

int main()
{
  Point A,B,C,D;
  int q;

  cin>>q;
  for(int i=0;i<q;i++){
    cin>>A.x>>A.y>>B.x>>B.y>>C.x>>C.y>>D.x>>D.y;
    printf("%.10f\n",getDistance(Segment(A,B),Segment(C,D)));
  }
  return 0;
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    map <vector <int>,ll> m;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        vector <int> count;
        count.resize(26,0);
        for(int j=0;j<10;j++)
            count[s[j]-97]++;
        m[count]+=1;
    }
    ll test=0;
    for(auto it=m.begin();it!=m.end();it++)
    {   
        ll val=it->second;
        test+=((val*(val-1))/2);
    }

    cout<<test<<endl;
    
    
    
    return 0;   
}


 
 


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

namespace ABC168
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
        }

        public static void a()
        {
            int n = int.Parse(Console.ReadLine());
            int a = n % 10;
            if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9)
            { Console.WriteLine("hon"); }
            else if(a == 3)
            { Console.WriteLine("bon"); }
            else
            { Console.WriteLine("pon"); }                
        }
    }
}


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

#define int long long
#define endl '\n'

const int mxN = 2e5+5;
int a[mxN];
int n,k;
bool check(int m) {
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x = max(0LL, a[i]/m-1);
        if ((x+1)*m < a[i]) x++;
        ans += x;
    }
    if (ans <= k) return 1;
    return 0;
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    cin>>n;
    cin>>k;
    for (int i = 0; i < n; i++) {
        cin>>a[i];
    }
    int l = 1, r = 1e9;
    int ans = 1e9;
    while(l<=r) {
        int m = (l+r)/2;
        if (check(m)) {
            ans = m;
            r = m - 1;
        }
        else l = m + 1;
    }
    cout<<ans;
}

Measured memory_bytes: 5208
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};


int main() {
int n,k;
cin>>n>>k;
int l[n];
REP(i,n) cin>>l[i];
sort(l,l+n,greater<int>());
int ans=0;
REP(i, k) ans+=l[i];
cout<<ans<<endl;
}


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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  
  if(abs(c - a) <= d || (abs(b - a) <=d && abs(b - c) <= d)){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}




Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n + 1];
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    int now = 1;
    int cnt = 0;
    while (now != 2 && cnt < n) {
        now = a[now];
        cnt++;
    }
    if (now == 2) cout << cnt << endl;
    else cout << -1 << endl;
    return 0;
}


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

int main() {
  long long x;
  cin >> x;
  long long ans = x / 11 * 2;
  if (x % 11 >= 1 && x % 11 <= 6) ans++;
  else if (x % 11 != 0) ans += 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import bisect

n, d, a = [int(i) for i in input().split()]

xh = []
for i in range(n):
    xh.append([int(i) for i in input().split()])

# 座標でソート
xh.sort()

x = [xh[i][0] for i in range(n)]
h = [xh[i][1] for i in range(n)]

# i番目のモンスターに、i-k番目で使った爆弾が届いた場合の最小のi-k
bomb_bisect = []
for i in range(n):
    bomb_bisect.append(bisect.bisect_left(x, x[i]-2*d))

bomb_ruisekiwa = [0 for i in range(n)]
# 左から貪欲に爆弾を使用
for i in range(n):
    bomb = 0
    if i == 0:
        bomb = (h[i]) // a + ((h[i]) % a != 0)
        bomb_ruisekiwa[i] = bomb
    else:
        if bomb_bisect[i] == i:
            damage = 0
        elif bomb_bisect[i]-1 < 0:
            damage = (bomb_ruisekiwa[i-1]) * a
        else:
            damage = (bomb_ruisekiwa[i-1] - bomb_ruisekiwa[bomb_bisect[i]-1]) * a
        if h[i] - damage > 0:
            bomb = (h[i] - damage) // a + ((h[i] - damage) % a != 0)
        bomb_ruisekiwa[i] = bomb + bomb_ruisekiwa[i-1]

print(bomb_ruisekiwa[-1])

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

#define ll long long
using namespace std;

int main(){

	ll n, ans = 0;
	cin >> n;

	ans += (n/500) * 1000;

	n -= (n/500)*500;

	ans += (n/5)*5;


	cout << ans << endl;

	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    ll x; cin >> x;
    ll r = x % 11;
    if(11 < x){
        if(r == 0) cout << x / 11 * 2 << endl;
        else if(r <= 6) cout << x / 11 * 2 + 1 << endl;
        else cout << x / 11 * 2 + 2 << endl;
    }else if(x <= 6){
        cout << 1 << endl;
    }else{
        cout << 2 << endl;
    }
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{
    char a,b;
    scanf("%c %c",&a,&b);
    int at=0,top=0;
    if(a=='H')
        at=1;
    if(b=='H')
        top=1;
    if( at==1 && top==1)
        printf("H");
    else if(at==0 && top ==0)
        printf("H");
    else if(at==1 && top ==0)
        printf("D");
    else if(at==0 && top ==1)
        printf("D");
   return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
int r,g,b;
cin>>r>>g>>b;
if(g%2==0&&b%4==0){
cout<<"YES"<<endl;
}
else if(g%2==1&&b%4==2){
cout<<"YES"<<endl;
}
else {
cout<<"NO"<<endl;
}


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            break;
        }
        a-=d;
        if(a<=0){
            cout<<"No"<<endl;
            break;
        }
    }    
    return 0;
}

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

using namespace std;

char s[200043];
int b[200043], dp[400043];

int main(int argc, char const *argv[]) {
  int n, k, c;
  scanf("%d%d%d", &n, &k, &c);
  scanf("%s", &s[0]);
  memset(b, -1, sizeof(b));
  int pos = 0;
  for (int t = 0; t < k; ++t) {
    while (s[pos] == 'x') {
      ++pos;
    }
    b[pos] = t;
    pos += c + 1;
  }
  for (int i = n - 1; i >= 0; --i) {
    dp[i] = dp[i + 1];
    if (s[i] == 'o') {
      dp[i] = max(dp[i], dp[i + c + 1] + 1);
    }
  }
  for (int i = 0; i < n; ++i) {
    if (b[i] != -1 && b[i] + dp[i + 1] < k) {
      printf("%d\n", i + 1);
    }
  }
  return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define N 500005
using namespace std;
int n,x,b[N];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&x);
		b[x+2]++;b[x+1]++;b[x]++;
	}int ans=0;
	for (int i=1;i<=100000+2;i++) ans=max(ans,b[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
n = input()
a = [[0] * n] * n

for i in range(n):
    a[i] = map(int, raw_input().split())

ans = -1e100
for j1 in range(n):
    f = [0] * n
    for j2 in range(j1, n):
        for i in range(n):
            f[i] += a[i][j2]
        dp = [0] * n
        for i in range(n):
            if i == 0: dp[i] = f[i]
            else: dp[i] = max(f[i], f[i] + dp[i-1])
            ans = max(ans, dp[i])

print ans

Measured memory_bytes: 6508
n, m, q = [int(i) for i in input().split()]

abcd = []
for i in range(q):
    abcd.append([int(i) for i in input().split()])

ans = 0
for a1 in range(1, 11):
    for a2 in range(a1, 11):
        for a3 in range(a2, 11):
            for a4 in range(a3, 11):
                for a5 in range(a4, 11):
                    for a6 in range(a5, 11):
                        for a7 in range(a6, 11):
                            for a8 in range(a7, 11):
                                for a9 in range(a8, 11):
                                    for a10 in range(a9, 11):
                                        # print(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
                                        A = [0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10]
                                        ans_ = 0
                                        if max(A) <= m:
                                            for i in range(q):
                                                if A[abcd[i][1]] - A[abcd[i][0]] == abcd[i][2]:
                                                    ans_ += abcd[i][3]
                                        ans = max(ans_, ans)

print(ans)

Measured memory_bytes: 72712
#include <stdio.h>

int main()
{
	int Num = 0;
	char chara[3*100000];
	int Sum[3*100000] = {0};
	scanf("%d", &Num);
	scanf("%s", chara);
	for(int i = 0; i < Num; i++)
	{
		if(i == 0)
		{
			for(int j = 1; j < Num; j++)
			{
				if(chara[j] == 'E') Sum[i]++;
			}
		}
		else
		{
			Sum[i] = Sum[i-1];
			if(chara[i-1] == 'W') Sum[i]++;
			if(chara[i] == 'E') Sum[i]--;
		}
	}
	
	int minimum = 3*100000;
	
	for(int i = 0; i < Num; i++)
	{
		if(minimum > Sum[i]) minimum = Sum[i];
	}
	printf("%d\n", minimum);
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[105],sum[105],c[105];
int main()
{
    int  a,p;
    scanf("%d%d",&a,&p);
   int num;
   num=a*3+p;
   printf("%d\n",num/2);
    return 0;
}


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


class Graph {
  public:
    int n_node;
    vector<vector<int>> edge;

    Graph(int n_node) : n_node(n_node){
      edge.resize(n_node);
    };

    void add_edge(int i, int j);
};

void Graph::add_edge(int i, int j) {
  // cout << i << ", " << j << endl;
  edge[i].push_back(j);
}

int main() {
  int w, h, c;
  int block;


  while (cin >> w >> h, w) {
    Graph g(w*h);

    rep (i, 2*h-1) {
      if (i%2 == 0) {
        // yoko
        rep (j, w-1) {
          cin >> block;
          int offset = w * (i / 2);
          int c = offset + j;
          if (block == 0) g.add_edge(c, c+1);
          if (block == 0) g.add_edge(c+1, c);
        }
      }
      else {
        // tate
        rep (j, w) {
          int offset = w * ((i - 1) / 2);
          cin >> block;
          c = j + offset;
          if (block == 0) g.add_edge(c, c+w);
          if (block == 0) g.add_edge(c+w, c);
        }
      }
    }

    // bfs
    queue<int> que;
    que.push(0);

    vector<int> cost(w*h);
    rep (i, w*h) cost[i] = 1001001001;
    cost[0] = 1;

    while (!que.empty()) {
      int current = que.front(); que.pop();

      for (int next_ : g.edge[current]) {
        if (cost[next_] == 1001001001) {
          que.push(next_);
          cost[next_] = cost[current] + 1;
          // cout << "current: " << current << ", next: " << next_ << endl;
          // cout << "current_cost: " << cost[current] << endl;
        }
      }
    }

    if (cost[w*h-1] == 1001001001) {
      cout << 0 << endl;
    }
    else {
      cout << cost[w*h-1] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3172
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
ll inf = (1LL << 50);

//bool operator< (pint a, pint b) {
	//return a.second < b.second;

//}



ll gcd(ll a, ll b) {

	if (b == 0)
		return a;

	return gcd(b, a % b);


}

ll max(ll a, ll b) {
	if (a < b) {
		return b;
	}
	else
		return a;

}

ll min(ll a, ll b) {
	if (a < b)
		return a;

	return b;
}




pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

vector<pint> list;


bool compare(pint l, pint r) {

	return l.second < r.second;
}


int main() {
	ll N, Y;

	cin >> N >> Y;
	bool flag = false;
	for(int i = 0; i <= N; i++){
		for (int j = 0; j <= N - i; j++) {
			if (Y == 10000 * i + j * 5000 + (N - i - j) * 1000) { 
				cout << i << " " << j << " " << N - i - j << endl; 
				return 0;
			}
				

		}
	}


	cout << -1 << " " << -1 << " " << -1 << endl;

	return 0;
}

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

int main() {
  char C;
  cin >> C;
  if (C == 'a' || C == 'e' || C == 'i' || C == 'o' || C == 'u') {
    cout << "vowel" << endl; 
  }
  else {
    cout << "consonant" << endl;
  }
}
 

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <cctype>
#include <cstdlib>
using namespace std;

#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a,b) (fabs((a)-(b)) < EPS)

#define MAX_N 2000
#define MAX_M 2000
#define MAX_S 2000
vector<vector<int> > cur(MAX_N, vector<int>(MAX_N, 0)), old(MAX_N, vector<int>(MAX_N, 0)); //消去数のカウント
int main(){
	vector<int> tl;
	int xl[MAX_S + 1];
	int s, n, m;
	cin >> s >> n >> m;
	for (int i = 1; i <= s; ++i) cin >> xl[i];
	for (int i = 0; i < n; ++i) {
		int t, p;
		cin >> t >> p;
		tl.push_back(t - xl[p]);
	}
	sort(tl.begin(), tl.end());
	for (int i = 1; i < m; ++i) { //回
		for (int j = i; j < n; ++j) { //まで
			for (int k = j; k < n; ++k) { //考慮範囲
				cur[j][k] = max(old[j-1][j-1] +(tl[k] - tl[j-1]) * j, cur[j-1][k]);
			}
		}
		cur.swap(old);
	}
	int sum = 0;
	for (int i = 0; i < n; ++i) {
		sum += tl[n-1] - tl[i];
	}
	cout << sum - max(cur[n-1][n-1], old[n-1][n-1]) << endl;
	return 0;
}

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

using namespace std;

void solve() {
	int n, m; cin >> n >> m;
	int left = 1, right = n;
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		left = max(left, a);
		right = min(right, b);
	}
	cout << max(right - left + 1, 0) << endl;
}

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

Measured memory_bytes: 384