akhauriyash/Code-Regression huggingface dataset:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
c = Counter(A)

# print('C', c)

ans = 0
for key in c.keys():
    v = c[key]
    v += c.get(key - 1, 0)
    v += c.get(key + 1, 0)
    ans = max(ans, v)
print(ans)


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(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(a))
#define size_of(a) (int)a.size()

int N, M;
int p[1010];

int main() {
	while (cin >> N >> M, N) {
		for_(i,0,N) cin >> p[i];
	
		vector<int> vp;
		vp.push_back(0);
		for_(i,0,N) vp.push_back(p[i]);
	
		vector<int> sum2;
		for_(i,0,N + 1) for_(j,0,N + 1) sum2.push_back(vp[i] + vp[j]);
	
		sort(allof(sum2));
		int s_size = size_of(sum2);
		int ans = 0;
		for_(i,0,s_size) {
			int sum = sum2[i];
			if (sum <= M) {
				int sub = M - sum;
				int lb = *(upper_bound(allof(sum2), sub) - 1);
				//cout << sub << " " << lb << endl;
				sum += lb;
				ans = max(ans, sum);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;

int main() {
  double a, b, x; cin >> a >> b >> x;
  double ans;
  if (2*x >= a*a*b) {
    ans = atan(2*(b/a-x/a/a/a))*180/PI;
  } else {
    ans = atan(a*b*b/2/x)*180/PI;
  }
  printf("%.6lf\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define vi vector<int>
#define si set<int>
#define pi pair<int,int>
#define li list<int>
#define fi first
#define in insert
#define se second
#define fr(i,n) for(i = 0 ; i < n ; i++)

int main()
{
    fio
    int n,i,j,k,m;

    cin>>n;
     double p[n];
     cout<<fixed<<setprecision(10);
    fr(i,n)
    cin>>p[i];
    double dp[n+1][n];
    memset(dp,0,sizeof(dp));
    dp[0][0] = 1-p[0];
    dp[1][0] = p[0];
    for(i = 1;i<n;i++)
    {
        dp[0][i] = (1-p[i])*dp[0][i-1];
    }
    for(i = 1;i<=n;i++)
    {
        for(j = 1 ; j < n;j++)
        {
            dp[i][j] = p[j]*dp[i-1][j-1] + (1-p[j])*dp[i][j-1];
        }
    }

    double sum = 0;
    for(i = (n+1)/2 ; i<=n ; i++)
    {
        sum+=dp[i][n-1];
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 70528
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	public static void main(String[] args) {
		int N=sc.nextInt();
		String S=sc.next();
		int ans=0;
		for(int i=1;i<S.length();i++) {
			
			String a=S.substring(0,i);
			String b=S.substring(i,S.length());
			
			//System.out.println(a+" "+b);
			
			int t=0;
			
			
			int v[]=new int[200];
			
			for(int ii=0;ii<a.length();ii++) {
				if(v[a.charAt(ii)]==0) {
					v[a.charAt(ii)]++;
				}
			}
			for(int ii=0;ii<b.length();ii++) {
				if(v[b.charAt(ii)]!=0) {
				t++;	
				v[b.charAt(ii)]=0;
				}
			}
			//System.out.println(t);
			ans=Math.max(ans,t);
			
		}
		
		p(ans);
		
	}
	
	
	
	
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 23636
///*.......................Shadman Sakib Utshob............................*///

#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define Boost           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#define pb              push_back
#define inf             1e9+8
#define mp              make_pair
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define ll              long long
#define pii             pair<ll,ll >
#define MOD             1000000007
#define fileout         freopen("output.txt","w",stdout)
#define mem(x,i)        memset(x,i,sizeof x)
#define Ones(x)         __builtin_popcount(x);
#define PI              acos(-1.0)
#define ff              first
#define ss              second
#define T               int t;cin>>t;while(t--)
#define ok              cout<<"ok"<<endl;
#define all(x)          (x).begin(),(x).end()
#define ordered_set     tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define nln	            cout<<endl;

int main()
{
    Boost;
    int i,j,n,ans=0,mon=0;
    cin>>n;
    int a[n+10],b[n+10],c[n+1];
    mem(a,0);
    for(i=1;i<=n-1;i++)
    {
        cin>>b[i];
    }
    a[1]=b[1];
    for(i=1;i<=n-1;i++)
    {
        if(a[i]>b[i])
        {
            a[i]=b[i];
        }
        a[i+1]=b[i];
    }
    rep1(i,n)
    {
        ans+=a[i];
    }
    cout<<ans<<endl;



}


Measured memory_bytes: 3612
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }


// Solution in the editorial
fn solve() {
    let mut n: Vec<i32> = get_word().bytes().map(|x| (x - b'0') as i32)
        .collect();
    n.reverse();
    let l = n.len();
    let mut sum = 0;
    // calculate 9n
    {
        let mut carry = 0;
        for i in 0 .. l {
            let tmp = n[i] * 9 + carry;
            let nc = tmp / 10;
            let tmp = tmp % 10;
            n[i] = tmp;
            carry = nc;
        }
        if carry > 0 {
            n.push(carry);
        }
    }
    for i in 0 .. l {
        sum += n[i];
    }
    for k in 0 .. l + 1 {
        if sum as usize <= 9 * k {
            println!("{}", k);
            return;
        }
        // add 9 to n, taking care of overflow
        let mut carry = 9;
        for i in 0 .. l {
            sum -= n[i];
            let tmp = n[i] + carry;
            let nc = tmp / 10;
            let tmp = tmp % 10;
            n[i] = tmp;
            carry = nc;
            // adjusting sum
            sum += n[i];
            if carry == 0 {
                // By this pruning, amortized computation time becomes O(1)
                break;
            }
        }
        if carry > 0 {
            n.push(carry);
            sum += carry;
        }
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 12540
#include<bits/stdc++.h>
#define MAX 51
#define inf 1<<29
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-12)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};

int h,w;
string grid[MAX];
int memo[MAX][MAX][4];

bool in(int y,int x){
  if(x<0 || y<0 || w<=x || h<=y)return false;
  return true;
}

bool cal(int sy,int sx,int gy,int gx,int sd){
  int cx=sx,cy=sy,cd=sd;
  memo[cy][cx][sd]=1;
  while(1){
    FOR(i,0,4){
      int nd = (cd+3+i)%4;
      int nx = cx+dx[nd],ny = cy+dy[nd];
      if(in(ny,nx) && grid[ny][nx]=='.'){
        cx = nx;
        cy = ny;
        cd = nd;
        break;
      }
      if(i==3)return false;
    }
    memo[cy][cx][sd]=1;
    if(cy==gy && cx==gx)break;
    if(cy==sy && cx==sx)return false;
  }
  return true;
}

bool chip(int y,int x){
  if(y==0 && x==0)return true;
  if(y==h-1 && x==0)return true;
  if(y==0 && x==w-1)return true;
  if(y==h-1 && x==w-1)return true;
  return false;
}

string solve(){
  FOR(i,0,h)
    FOR(j,0,w)
      FOR(k,0,4)memo[i][j][k] = 0;
  if(!cal(0,0,h-1,0,0))return "NO";
  if(!cal(h-1,0,h-1,w-1,1))return "NO";
  if(!cal(h-1,w-1,0,w-1,2))return "NO";
  if(!cal(0,w-1,0,0,3))return "NO";
  FOR(i,0,h){
    FOR(j,0,w){
      int sum = memo[i][j][0]+memo[i][j][1]+memo[i][j][2]+memo[i][j][3];
      if(chip(i,j) && sum!=2)return "NO";
      if(!chip(i,j) && 1<sum)return "NO";
    }
  }
  return "YES";
}

int main()
{
  while(cin>>h>>w && h){
    FOR(i,0,h)cin>>grid[i];
    cout<<solve()<<endl;
  }
  return 0;
}



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

int main() {
    int m,f,r;

    cin >> m >> f >> r;
    while(m!=-1 || f != -1 || r!= -1) {
        string grade;
        int score;

        score = m+f;
        if(m==-1 || f ==-1)
        {
            grade = "F";
        }
        else if(score >= 80)
        {
            grade = "A";
        }
        else if(score < 80 && score >= 65)
        {
            grade = "B";
        }
        else if(score < 65 && score >= 50)
        {
            grade = "C";
        }
        else if(score < 50 && score >= 30)
        {
            if(r>=50)
                grade = "C";
            else
                grade = "D";
        }
        else
            grade = "F";

        cout << grade << endl;

        cin >> m >> f >> r;
    }
}

Measured memory_bytes: 3172
import functools
import itertools
import operator

required_char = 'MARCH'
N = int(input())
name_counter = {s: 0 for s in required_char}
for _ in range(N):
    S = input()
    if S[0] in required_char:
        name_counter[S[0]] += 1
ans = 0
for cmb in itertools.combinations(name_counter.values(), 3):
    ans += functools.reduce(operator.mul, cmb)
print(ans)


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <complex>
#include <math.h>
#include <iomanip>
using namespace std;
//using ll = long long;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
//クラスカル法<=UnionFind
#define MAX 100000

int par[MAX],rank_[MAX];
void init(int n){
    for(int i = 0; i < n; i++){
        par[i] = i;
        rank_[i] = 0;
    }
}
int find(int x){
    if (par[x] == x) return x;
    return par[x] = find(par[x]); 
}

void unite(int x,int y){
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank_[x] < rank_[y]){
        par[x] = y;
    } else {
        par[y] = x;
        if (rank_[x] == rank_[y]){
            rank_[x]++;
        }
    }
}
bool same(int x,int y){
    return (find(x) == find(y));
}

struct edge{ int u,v,cost; };

bool comp(const edge &e1, const edge &e2){
    return e1.cost < e2.cost;
}
int V,E;
edge es[MAX];

int kruskal(){
    sort(es,es+E,comp); //comp使う（sort）
    init(V);
    int res = 0;
    for (int i = 0; i < E; i++){
        edge e = es[i];
        if (!same(e.u, e.v)){
            unite(e.u, e.v);
            res += e.cost; //結合＋コスト増加
        }
    }
    return res;
}

int main(){
    cin >> V >> E;
    for (int i = 0; i < E; i++){
        int s,t,w; cin >> s >> t >> w;
        es[i] = (edge){s,t,w};
    }
    cout << kruskal() << endl;
    return 0;
}
  




Measured memory_bytes: 4368
import java.util.ArrayList;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		@SuppressWarnings("unchecked") ArrayList<Integer>[] jobs = new ArrayList[m + 1]; // 遅延日数ごとに仕事をグルーピングする
		for ( int i = 0; i <= m; i++ ) {
			ArrayList<Integer> a = new ArrayList<>();
			a.add(0); // ダミー要素
			jobs[i] = a;
		}

		for ( int i = 0; i < n; i++ ) {
			int d = in.nextInt();
			int f = in.nextInt();
			if ( d > m ) continue; // 遅延日数的に候補になりえない仕事は除外
			jobs[d].add(f);
		}

		long total = 0;
		PriorityQueue<Integer> pool = new PriorityQueue<Integer>(Collections.reverseOrder()); // job候補のプール
		pool.add(0); // ダミー

		// m日目をゼロとして考え後退していく days:残り日数
		for ( int today = 0; today <= m; today++ ) {
			pool.addAll(jobs[today]);
			int daypay = pool.poll();
			total += daypay;
		}

		System.out.println(total);
		in.close();
	}
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    cout << int(ceil(double((a + b) / 2.0))) << endl;

    return 0;
}


Measured memory_bytes: 256
n,m=map(int, input().split())
a=[list(map(int, input().split())) for i in range(m)]
d={}
for i,j in a:
    d[i]=d.get(i,set())|{j}
    d[j]=d.get(j,set())|{i}
path=a[0][:]
sp=set(path)
while d[path[-1]]-sp:
    t=d[path[-1]]-sp
    t=t.pop()
    path.append(t)
    sp.add(t)
path=path[::-1]
while d[path[-1]]-sp:
    t=d[path[-1]]-sp
    t=t.pop()
    path.append(t)
    sp.add(t)
print(len(path))    
print(*path)

Measured memory_bytes: 60752
nm = list(map(int,input().rstrip().split()))
n = nm[0]
m = nm[1]
arr = list(map(int,input().rstrip().split()))
vote = sum(arr)
cou = 0
com = (1/(4*m))*vote
for i in range(len(arr)):
    if arr[i] >= com:
        cou += 1
if cou >= m :
    print('Yes')
else:
    print("No")

Measured memory_bytes: 3064
using System;

class Program {
	static void Main()
	{
		var sl = Console.ReadLine().Split(' ');
		var a = int.Parse(sl[0]);
		var b = int.Parse(sl[1]);
		
		for (var c = 1; c <= 3; c++)
			if ((a * b * c) % 2 != 0)
			{
				Console.WriteLine("Yes");
				return;
			}
		
		Console.WriteLine("No");
		
	}
}

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

namespace ProblemD
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            long ret = 0;
            if(N != 1)
            {
                //ret = 1 + (((N - 1) + 2) * (N - 2)) / 2;
                ret = N * (N - 1) / 2;
            }
            Console.WriteLine(ret);
        }
    }
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, m;
  std::cin >> n >> m;

  std::vector<int64_t> a(n, 0);
  std::vector<bool> flag(n, false);
  int64_t ans = 0, pen = 0;

  for (int64_t i = 0; i < m; i++) {
    int64_t p;
    std::string s;
    std::cin >> p >> s;
    p--;
    if (s == "WA") {
      a[p]++;
    } else {
      if (!flag[p]) {
        ans++;
        pen += a[p];
        flag[p] = true;
      }
    }
  }

  std::cout << ans << " " << pen << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define sf scanf
#define pf printf
#define pi acos(-1)
#define time_save ios_base::sync_with_stdio(false); cin.tie(NULL);
ll ar[1000006];

#define mx 1000005
ll prime[mx];

bool vis[mx];

void sieve()
{
    ll x=sqrt((ll)mx);
    for(ll i=3; i<=x; i+=2)
        {
        if(vis[i]==0)
        {
            for(ll j=i*i; j<mx; j+=2*i)
                vis[j]=1;
        }
    }
    prime[0]=2;
    ll in=1;
    for(ll i=3; i<mx; i+=2)
    {
        if(vis[i]==0)
        {
            prime[in]=i;
            in++;
        }
    }
}
int main()
{
    sieve();
    //time_save;
    ll n,gc;
    map<ll,ll>mp;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    gc=ar[0];
    for(ll i=1;i<n;i++)
    {
        gc=__gcd(gc,ar[i]);
    }
    ll flag=0;
    if(gc==1)
    {
        for(ll i=0;i<n;i++)
        {
            ll val=ar[i];
            for(ll j=0;prime[j]<=sqrt(ar[i]);j++)
            {
                if(val%prime[j]==0)
                {
                    mp[prime[j]]++;
                    if(mp[prime[j]]>1)
                    {
                        flag=1;
                        break;
                    }
                    while(val%prime[j]==0)
                        val/=prime[j];
                }
            }
            if(val!=1)
                mp[val]++;
            if(mp[val]>1)
            {
                flag=1;
                break;
            }
        }
        if(flag==1)
            cout<<"setwise coprime"<<endl;
        else
            cout<<"pairwise coprime"<<endl;
    }
    else
        cout<<"not coprime"<<endl;
    return 0;
}


Measured memory_bytes: 13048
#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;

// 負けるときの状況
// (x,y) = (0,1), (1,1)
// (0,1) パターン
// (2,0) => (0,1)
// (3,1) => (1,2) => (2,0) => (0,1)
// (1,1) パターン
// (2,2) => (3,0) => (1,1)
// (2,5) => 0,6 - 3,0 - 1,1
// (2,4) - 0,5 - 1,3 - 2,1
//             - 2,1


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll x,y; cin>>x>>y;
  if(abs(x-y)>=2) cout<<"Alice"<<endl;
  else cout<<"Brown"<<endl;
  
}

Measured memory_bytes: 3656
N,M=map(int,input().split())
P=[]
A=[]
for i in range(M):
    n,a=input().split()
    P.append(int(n))
    A.append(a)

D=['0']*N
Z=[0]*N
a=0
p=0
for i in range(M):
  if D[P[i]-1]!='AC'and A[i]=='WA':
    Z[P[i]-1]+=1
    D[P[i]-1]='WA'
  elif D[P[i]-1]!='AC' and A[i]=='AC':
    a+=1
    p+=Z[P[i]-1]
    D[P[i]-1]='AC'

print(a,p)


Measured memory_bytes: 14920
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    set<int> water, sugar;
    rep(i, F) {
        rep(j, F) {
            if (100*(A*i + B*j) <= F) {
                water.insert(100*A*i + 100*B*j);
            }
            if (C*i + D*j <= F) {
                sugar.insert(C*i + D*j);
            }
        }
    }
    vector<int> w(water.begin(), water.end()), s(sugar.begin(), sugar.end());
    int denth1=0, denth2 = 1;
    int ansW=w[w.size()-1], ansS=0;
    rep(i, w.size()) {
        rep(j, s.size()) {
            if (w[i]+s[j] > 0 && w[i] + s[j] <= F && denth1*(w[i]+s[j]) < s[j]*denth2 && s[j] <= w[i]/100*E) {
                ansW = w[i]; ansS = s[j];
                denth1 = s[j]; denth2 = w[i]+s[j];
            }
        }
    }
    //cout << denth << endl;
    cout << ansW+ansS << " " << ansS << endl;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
  string S;
  int counter=0;
  std::cin >> S;
  for (size_t i = 0; i < 6; i++) {
    if(S[i]=='1'){
      ++counter;
    }
  }
  std::cout << counter << '\n';
  return 0;
}


Measured memory_bytes: 256
from math import floor


def main():
    a, b = map(int, input().split())
    tmp = True
    for n in range(1, 1251):
        if floor(n * 0.08) == a and floor(n * 0.1) == b:
            print(n)
            tmp = False
            break
    if tmp:
        print(-1)


if __name__ == '__main__':
    main()



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

int main(){
    int N;
    cin >> N;
    
    ll sum=0;
    vector<int> inu(N);
    rep(i,N){
        int x;
        cin >> x;
        sum = sum xor x;
        inu[i] = x;
    }
    
    rep(i,N){
        ll ans = sum xor inu[i];
        cout << ans;
        if(i < N-1) cout << " ";
    }cout << endl;
}


Measured memory_bytes: 4004
while(s=?/+gets.gsub(/\d+/){|k|?1*k.to_i})!~/#/
n=s.reverse.index ?/
a,b,c,d=gets.split.map &:to_i
s[n*a-n+b]=?1
s[n*c-n+d]=?b
$><<s[1..-1].gsub(/1+/,&:size)
end

Measured memory_bytes: 8748
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f("Left", A, B) :- A > B, !.
f("Balanced", A, B) :- A =:= B, !.
f("Right", A, B) :- A < B, !.

main :-
    get_number(A, B),
    get_number(C, D),
    f(X, A + B, C + D),
    writeln(X).


Measured memory_bytes: 8032
#include <bits/stdc++.h>
using namespace std;
#define long long long
const long MOD = 1e9+7;
signed main()
{
    long test;
    test=1;
    // cin>>test;
    while(test--){
    long i,j,a,b,n,x,ans,most,index,c,maxi=0,temp,aw,bw,w;
    cin>>w>>a>>b;
    aw=a+w;
    bw=b+w;
    if((a>=b and a<=bw) || b>=a and b<=aw)
    {
        cout<<0;
        return 0;
    }
    cout<<abs(min(abs(aw-b),abs(bw-a)));
    }
}

Measured memory_bytes: 256
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(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(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	int N;
	string S;
	cin >> N;
	cin >> S;
	
	Vec< pii > rng;
	int prv = -1;
	for_(i,0,N) {
		if (S[i] == '1' && prv == -1) prv = i;
		if (S[i] == '0' && prv != -1) {
			rng.push_back(pii(prv, i));
			prv = -1;
		}
	}
	if (prv != -1) rng.push_back(pii(prv, N));
	
	Vec< Vec< int > > comp;
	int m = rng.size(), lft = 0, rgt = 1;
	while (lft < m) {
		while (rgt < m && rng[rgt-1].second + 1 == rng[rgt].first) ++rgt;
		Vec< int > add;
		for_(i,lft,rgt) add.push_back(rng[i].second - rng[i].first);
		comp.push_back(add);
		lft = rgt;
		++rgt;
	}
	
	int n = comp.size(), ans = 0;
	for_(i,0,n) {
		int C = comp[i].size();
		if (C == 1) continue;
		
		Vec< int > cp = comp[i];
		/*
		for (int x : cp) cerr << x << " ";
		cerr << endl;
		*/
		Vec< Vec< int > > dp(C+1, Vec< int >(4, -1));
		dp[0][0] = 0;
		for_(k,0,C) for_(f,0,4) {
			if (dp[k][f] == -1) continue;
			
			maxUpdate(dp[k+1][3], dp[k][f]);
			
			if (f == 1) {
				maxUpdate(dp[k+1][0], dp[k][f] + cp[k]);
				if (cp[k] == 1) maxUpdate(dp[k+1][0], dp[k][f] + cp[k-1] - 1);
				if (cp[k] > 1) {
					maxUpdate(dp[k+1][1], dp[k][f] + cp[k-1] - 1);
					maxUpdate(dp[k+1][2], dp[k][f] + cp[k] - 1);
				}
			}
			
			if (f == 2) {
				maxUpdate(dp[k+1][0], dp[k][f] + cp[k]);
				if (cp[k] > 1) {
					maxUpdate(dp[k+1][1], dp[k][f] + 1);
					maxUpdate(dp[k+1][2], dp[k][f] + cp[k] - 1);
				}
			}
			
			if (f == 3) {
				maxUpdate(dp[k+1][0], dp[k][f] + cp[k]);
				if (cp[k] == 1) maxUpdate(dp[k+1][0], dp[k][f] + cp[k-1]);
				if (cp[k] > 1)	{
					maxUpdate(dp[k+1][1], dp[k][f] + cp[k-1]);
					maxUpdate(dp[k+1][2], dp[k][f] + cp[k] - 1);
				}
			}
		}
		
		int add = 0;
		for_(f,0,4) maxUpdate(add, dp[C][f]);
		//cerr << "#" << add << endl;
		ans += add;
	}
	cout << ans << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 8056
#include<bits/stdc++.h>
#define chal ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lli long long
using namespace std;
int main()
{
    int t;
    t=1;
    while(t--)
    {
        long long n;
        cin>>n;
        long long a[n],b[n],c[n],res[n],i;
        for(i=0;i<n;i++)
        {
            cin>>a[i];
        }
        b[0]=a[0];
        for(i=1;i<n;i++)
        {
            b[i]=b[i-1]^a[i];
        }
        c[n-1]=a[n-1];
        for(i=n-2;i>=0;i--)
        {
            c[i]=c[i+1]^a[i];
        }
        for(i=0;i<n;i++)
        {
            if(i==0)
                res[i]=c[i+1];
            else if(i==n-1)
                res[i]=b[i-1];
            else
                res[i]=b[i-1]^c[i+1];
        }
        for(i=0;i<n;i++)
            cout<<res[i]<<" ";

    }
    return 0;
}


Measured memory_bytes: 9848
#include<bits/stdc++.h>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		 int F=1,n=0;
		 char ch;
		 while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		 ch=='-'?F=0:n=ch-'0';
		 while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		 return F?n:-n;
	}
	long long G()
	{
		 long long F=1,n=0;
		 char ch;
		 while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		 ch=='-'?F=0:n=ch-'0';
		 while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		 return F?n:-n;
	}
}
int R(int l,int r)
{
	return (rand()<<15|rand())%(r-l+1)+l;
}
char s[222222];
struct edge
{
	int to;
	int next;
}e[666666];
int pe=222222;
void insert(int a,int to)
{
	e[pe]=(edge){to,e[a].next};
	e[a].next=pe++;
}
int deg[222222][2];
int q[222222],hq,tq;
int vis[222222];
int main()
{
	int n=io::F(),m=io::F(); 
	scanf("%s",s+1);
	for(register int i=1;i<=m;++i)
	{
		int x=io::F();
		int y=io::F();
		insert(x,y);
		insert(y,x);
	}
	for(register int i=1;i<=n;++i)
		for(register int p=e[i].next;p;p=e[p].next)
			deg[i][s[i]==s[e[p].to]]++;
	for(register int i=1;i<=n;++i)
		if(dmin(deg[i][0],deg[i][1])==0)q[tq++]=i,vis[i]=1;
	for(;hq!=tq;++hq)
	{
		int o=q[hq];
		for(register int p=e[o].next;p;p=e[p].next)
		{
			--deg[e[p].to][s[e[p].to]==s[o]];
			if(vis[e[p].to]==0&&dmin(deg[e[p].to][0],deg[e[p].to][1])==0)q[tq++]=e[p].to,vis[e[p].to]=1;
		}
	}
	if(tq!=n)puts("Yes");
		else puts("No");
	return 0;
}


Measured memory_bytes: 8320
#include<iostream>
#include<cstdlib>
#include<cstdio>
using namespace std;

int top, S[1000];

void push(int x)
{
	S[top] = x;
	top++;
}

int pop()
{
	top--;
	return S[top];
}

int main()
{
	top = 0;
	int a, b;
	char s[100];

	while (scanf("%s",s) != EOF)
	{
		if (s[0] == '+')
		{
			a = pop();
			b = pop();
			push(a + b);
		}

		else if (s[0] == '-')
		{
			a = pop();
			b = pop();
			push(b - a);
		}

		else if (s[0] == '*')
		{
			a = pop();
			b = pop();
			push(a * b);
		}

		else
			push(atoi(s));

	}

	cout << pop() << endl;


	return 0;
}


Measured memory_bytes: 3236
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> input = new ArrayList<String>();
		String buf;
		while((buf = br.readLine()) != null){
			input.add(buf);
		}
		for(String str : input){
			System.out.println(unzipString(str));
		}
	}
	public static String zipString(String str){
		StringBuffer bf = new StringBuffer();
		return bf.toString();
	}
	public static String unzipString(String str){
		StringBuffer bf = new StringBuffer();
		char[] c = str.toCharArray();
		for(int i = 0; i < c.length; i++){
			if(c[i] == '@'){
				int n = c[++i] - '0';
				char tmp = c[++i];
				for(int j = 0; j < n; j++){
					bf.append(tmp);
				}
			}
			else{
				bf.append(c[i]);
			}
		}
		return bf.toString();
	}
}

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

class Dmondai
{
    static void Main()
    {
        var nw = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var N = nw[0];
        var W = nw[1];
        //index,重さ＝価値
        var dp = new long[N + 1, W + 1];
        for (int i = 0; i <= N; i++) for (int j = 0; j <= W; ++j) dp[i, j] = 0;
        for (int i=0;i<N;++i)
        {
            var wv = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
            var w = wv[0];
            var v = wv[1];
            for (int j=0;j<=W;++j)
            {
                if (dp[i, j] == 0) continue;
                dp[i + 1, j] = Math.Max(dp[i+1,j],dp[i,j]);
                if (j + w <= W) dp[i + 1, j + w] = Math.Max(dp[i+1,j+w],dp[i,j]+v);
            }
            dp[i+1, w] = Math.Max(dp[i,w],v);
        }
        var ans = 0L;
        for (int i=0;i<=W;++i)
        {
            ans = Math.Max(dp[N,i],ans);
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 92000
value_index = dict()
n, x, m = map(int, input().split())
a = [0] * (m + 1)
s = [0] * (m + 2)

for i in range(m + 1):
    a[i] = x % m
    s[i+1] = s[i] + a[i]
    if i == n - 1:
        print(s[i+1])
        quit()
    if a[i] in value_index:
        break
    value_index[a[i]] = i
    x = x * x % m

l = value_index[a[i]]
r = i

loop_sum = s[r] - s[l]
loop_n = (n - l) // (r - l)
rem = (n - l) % (r - l)

ans = s[l] + loop_n * loop_sum + s[l+rem] - s[l]
print(ans)


Measured memory_bytes: 74124
#include <bits/stdc++.h>
// e.g. sort(all(a), [](int a1, int a2) { return a1 < a2; });
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

vector<int> a(200010);

int main() {
  int k,n;
  cin >> k >> n;
  a.resize(n);
  rep(i,n) cin >> a[i];

  // a[0] から a[0] までぐるっと一周まわる
  // かつ、差分が一番大きい場所をメモしておく

  int sum = 0;
  int max_diff = 0;
  rep(i,n) {
    if (i == 0) {
      sum += k + a[0] - a[n-1];
      max_diff = max(k + a[0] - a[n-1], max_diff);
    } else {
      sum += a[i] - a[i-1];
      max_diff = max(a[i] - a[i-1], max_diff);
    }
  }

  cout << sum - max_diff << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {
	static private Scanner sc = new Scanner(System.in);
	static int TC;
	public static void main(String[] args) {
		TC = sc.nextInt();
		for (int i = 0; i < TC; i++) {
			read();
			solve();
		}
	}
	
	static int gx,gy;
	static int M;
	static int[][] W;
	
	public static boolean read() {
		gx = sc.nextInt();
		gy = sc.nextInt();
		M = sc.nextInt();
		W = new int[gy * 2 + 1][gx * 2 + 1];
		for(int i =0; i < M; i++) {
			int x1 = sc.nextInt();
			int y1 = sc.nextInt();
			int x2 = sc.nextInt();
			int y2 = sc.nextInt();
			if (x1 == x2) {
				int ly = min(y1 * 2, y2 * 2), uy = max(y1 * 2, y2 * 2);
				for (int y = ly + 1; y < uy; y += 2) {
					W[y][x1 * 2] = 1;
				}
			} else {
				int lx = min(x1 * 2, x2 * 2), ux = max(x1 * 2, x2 * 2);
				for (int x = lx + 1; x < ux; x += 2) {
					W[y1 * 2][x] = 1;
				}
			}
			
		}

		return true;
	}
	
	public static void solve() {
		int[][] dp = new int[gy * 2 + 1][gx * 2 + 1];
		dp[0][0] = 1;
		for (int i = 2; i < gx * 2 + 1; i += 2) {
			if (W[0][i - 1] == 1) {
				dp[0][i] = 0;
			} else {
				dp[0][i] = dp[0][i - 2];
			}
		}
		
		for (int i = 2; i < gy * 2 + 1; i += 2) {
			if (W[i - 1][0] == 1) {
				dp[i][0] = 0;
			} else {
				dp[i][0] = dp[i - 2][0];
			}
		}
		
		for (int i = 2; i < gy * 2 + 1; i += 2) {
			for (int j = 2; j < gx * 2 + 1; j += 2) {
				dp[i][j] = 0;
				if (W[i - 1][j] == 0) dp[i][j] += dp[i - 2][j];
				if (W[i][j - 1] == 0) dp[i][j] += dp[i][j - 2];
			}
		}
		if (dp[gy * 2][gx * 2] == 0) {
			System.out.println("Miserable Hokusai!");
		} else {
			System.out.println(dp[gy * 2][gx * 2]);
		}
	}
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

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

    if (a > 2 * b) {
        cout << a - 2 * b << endl;
    } else if (a <= 2 * b) {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys


def bfs(matrix):
    distances = [-1 for _ in range(len(matrix))]
    queue = [0]
    distances[0] = 0

    while 0 < len(queue):
        node_id = queue.pop(0)  # Dequeue
        distance = distances[node_id]
        for index, candidate in enumerate(matrix[node_id]):
            if candidate == 1 and distances[index] == -1:
                # ???????????¢????¨?????????????????????? node
                queue.append(index)
                distances[index] = distance + 1

    return distances

if __name__ == "__main__":
    # ??????????????????
    # lines = [
    #     "4",
    #     "1 2 2 4",
    #     "2 1 4",
    #     "3 0",
    #     "4 1 3",
    # ]
    lines = sys.stdin.readlines()
    dimension = int(lines[0])
    matrix = [[0 for _ in range(dimension)] for _ in range(dimension)]

    # Set edge info
    for index, line in enumerate(lines[1:]):
        for edge in [int(x) for x in line.strip().split(" ")[2:]]:
            matrix[index][edge - 1] = 1

    distances = bfs(matrix)
    for index, distance in enumerate(distances):
        print("%d %d" % (index + 1, distance))

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

using namespace std;
#define rep(j,n) for(int j=0;j<(n);j++)

using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

int main(int, char**)
{
    int n, m, k;
    cin >> n >> m >> k;

    vector<int> a(n), b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];

    ll sum = 0;
    int maxa = n;
    rep(i,n) {
      if (sum + a[i] > k) {
        maxa = i;
        break;
      }
      sum += a[i];
    }
    int ans = maxa;
    rep(i,m) {
      while (sum + b[i] > k && maxa >= 1) {
        sum -= a[maxa-1];
        maxa--;
      }
      if (sum + b[i] > k) break;
      sum += b[i];
      ans = max(ans, maxa+i+1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4836
#include <stdio.h>

int main(){
  int n,i;
  char s[10005];
  scanf("%d",&n);
  scanf("%s",&s);
  for(i=0;s[i]!=0;i++){
    s[i]+=n;
    if(s[i]>'Z') s[i]-=26;
  }
  printf("%s",&s);
  return(0);
}

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

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

Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

// https://atcoder.jp/contests/abc073/tasks/abc073_d
// ワーチャルフロイド法 O(n^3) nはたかだか200 -> 8,000,000(10^6)
// 上記の結果を利用して、全組み合わせで試す。R!。Rはたかだか8 -> 40,320
public class Main {
    final static int INF = 100000000;

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

        int[] r = new int[R];
        for (int i = 0; i < R; i++) r[i] = sc.nextInt() - 1;

        int[] A = new int[M];
        int[] B = new int[M];
        int[] C = new int[M];

        int[][] distance = new int[N][N];
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++) {
                distance[i][j] = INF;
            }
        }

        for (int i =0; i < M; i++){
            A[i] = sc.nextInt() - 1;
            B[i] = sc.nextInt() - 1;
            C[i] = sc.nextInt();
            distance[A[i]][B[i]] = C[i];
            distance[B[i]][A[i]] = C[i];
        }

        solver(N, r, distance);
    }

    public static void solver(int N, int[] r, int[][] distance) {
        //for(int i = 0; i < N; i++){
        //    out.println(Arrays.toString(distance[i]));
        //}

        // 全ペアの最短経路を計算
        warshallFloyd(N, distance);

        //for(int i = 0; i < N; i++){
        //    out.println(Arrays.toString(distance[i]));
        //}

        // 昇順にソート
        Arrays.sort(r);

        int minimumCost = Integer.MAX_VALUE;
        do{
            int cost = 0;
            for(int i = 0; i < r.length - 1; i++){
               cost += distance[r[i]] [r[i+1]];
            }
           minimumCost = Math.min(minimumCost, cost);
        } while(nextPermutation(r));

        out.println(minimumCost);
    }

    public static void warshallFloyd(int vertex, int[][] distance){
        for(int k = 0; k < vertex; k++) {           // 経由する頂点
            for(int i = 0; i < vertex; i++){        // スタートの頂点
                for(int j = 0; j < vertex; j++ ){   // ゴールの頂点
                    if(distance[i][j] > distance[i][k] + distance[k][j]){
                        distance[i][j] = distance[i][k] + distance[k][j];
                    }
                }
            }
        }
    }

    // http://d.hatena.ne.jp/tomerun/20081203/1228321480
    // 配列版
    public static boolean nextPermutation(int[] a) {
        for (int i = a.length - 1; i > 0; --i) {
            if (a[i - 1] < a[i]) {
                int swapIndex = find(a[i - 1], a, i, a.length - 1);
                int temp = a[swapIndex];
                a[swapIndex] = a[i - 1];
                a[i - 1] = temp;
                Arrays.sort(a, i, a.length);
                return true;
            }
        }
        return false;
    }

    // destより大きい要素の中で最小のもののインデックスを二分探索で探す
    private static int find(int dest, int[] a, int s, int e) {
        if (s == e) {
            return s;
        }
        int m = (s + e + 1) / 2;
        return a[m] <= dest ? find(dest, a, s, m - 1) : find(dest, a, m, e);
    }
}


Measured memory_bytes: 47996
# -*- coding:utf-8 -*-
import math

def walk(d,angle):
    x = d*math.cos(angle)
    y = d*math.sin(angle)
    p = [x,y]
    return p

x,y,angle = 0,0,90
while True:
    d, a = map(int, input().split(","))
    p = walk(d,math.radians(angle))
    x += p[0]
    y += p[1]
    angle -= a
    if d == a == 0:
        break

print(int(x))
print(int(y))

Measured memory_bytes: 7896
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	string S;
	while (cin >> S) {
		lint N = S.size();
		rep(i, N) {
			if (S[i] == '@') {
				rep(j, lint(S[i + 1]-'0')) {
					cout << S[i + 2];
				}
				i += 2;
			}
			else {
				cout << S[i];
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n, m, p = 1;
vpii v;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, m){
    int a, b;
    cin >> a >> b;
    v.pb(pii(b, a));
  }
  sort(rng(v));
  int ans = 0;
  each(itr, v){
    if(itr->se >= p){
      ans++;
      p = itr->fi;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1400
#include<stdio.h>
#define T 1
#define F 0

int isPrime(int a)
{
  int i;

  if(a < 2)
    return F;
  else if(a == 2)
    return T;
  if (a%2 == 0)
    return F;

  for(i=3; i*i<=a; i+=2){
    if (a%i == 0)
      return F;
  }

  return 1;
}

int main()
{
  int n,a,i;
  int c = 0;

  scanf("%d",&n);

  for (i=0; i<n; i++){
    scanf("%d",&a);
    if(isPrime(a))
      c++;
  }

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

  return 0;
}


Measured memory_bytes: 2056
s = raw_input()
for _ in [0]*int(raw_input()):
  I = raw_input().split()
  a = I[0][2]
  b = int(I[1])
  c = int(I[2])+1
  if a=='p': s=s[:b]+I[3]+s[c:]
  elif a=='v': s=s[:b]+s[b:c][::-1]+s[c:]
  else: print s[b:c]

Measured memory_bytes: 4220