akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
    #include<map>
    #include<deque>
    #include<algorithm>
    #include<string>
    #include<cctype>
    #include<iomanip>
    #include<vector>
    #include<queue>
     
    using namespace std;
    #define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
    #define rep0(i,n) REP(i,0,n)
    #define rep1(i,n) REP(i,1,n+1)
    #define shosu setprecision(10)
    typedef long long ll;
    typedef pair<ll,ll> P;
    ll longinf=1ll<<60;
     
     
    int T;
    ll A,B,C,D;
    ll gcd(ll a,ll b){
        if(a>b) return gcd(b,a);
        if(a==0) return b;
        else return gcd(b%a,a);
    }
     
    int main(){
        cin>>T;
        //cout<<gcd(24,8)<<endl;
        rep0(gu,T){
            cin>>A>>B>>C>>D;
            bool ok=false;
            if(B<=C+gcd(A,gcd(B,D))&&B<=D) ok=true;
            ll dd=gcd(B,D);
            ll aa=A-((A-B+gcd(B,D)-1)/gcd(B,D))*gcd(B,D);
          if(aa<=C&&B<=D) ok=true;
            else{
                if(B==D){
                    if(A%B<=C) ok=true; 
                }
            }
          if(A<B) ok=false;
            if(ok) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
        return 0;
    }

Measured memory_bytes: 256
//https://atcoder.jp/contests/agc030/tasks/agc030_d
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};
int N,Q;
int A[3123];
int X[3123];
int Y[3123];
constexpr int mod = 1e9+7;
LL dp[3123][3123];
LL last_update[3123][3123];
LL x[3123];
int main(){
    cin>>N>>Q;
    for(int i:range(N))cin>>A[i];
    for(int i:range(Q)){
        cin>>X[i]>>Y[i];
        X[i]--;
        Y[i]--;
    }
    x[0]=1;
    for(int i:range(3120)){
        x[i+1]=x[i]*2%mod;
    }
    for(int i:range(N)){
        for(int j:range(i+1,N)){
            if(A[i]<A[j]){
                dp[i][j]++;
            }
            if(A[i]>A[j]){
                dp[j][i]++;
            }
        }
    }
    using T=tuple<int,int,LL>;
    queue<T> que;
    for(int q:range(Q)){
        for(int i:range(N)){
            if(i!=X[q]){
                dp[i][Y[q]]=dp[i][Y[q]]*x[q-last_update[i][Y[q]]]%mod;
                last_update[i][Y[q]]=q+1;
                dp[Y[q]][i]=dp[Y[q]][i]*x[q-last_update[Y[q]][i]]%mod;
                last_update[Y[q]][i]=q+1;

                que.push(T(i,X[q],dp[i][Y[q]]));
                que.push(T(X[q],i,dp[Y[q]][i]));
            }
            if(i!=Y[q]){
                dp[i][X[q]]=dp[i][X[q]]*x[q-last_update[i][X[q]]]%mod;
                last_update[i][X[q]]=q+1;
                dp[X[q]][i]=dp[X[q]][i]*x[q-last_update[X[q]][i]]%mod;
                last_update[X[q]][i]=q+1;

                que.push(T(i,Y[q],dp[i][X[q]]));
                que.push(T(Y[q],i,dp[X[q]][i]));
            }
        }
        dp[X[q]][Y[q]]=dp[X[q]][Y[q]]*x[q-last_update[X[q]][Y[q]]]%mod;
        last_update[X[q]][Y[q]]=q+1;
        dp[Y[q]][X[q]]=dp[Y[q]][X[q]]*x[q-last_update[Y[q]][X[q]]]%mod;
        last_update[Y[q]][X[q]]=q+1;
        que.push(T(X[q],Y[q],dp[Y[q]][X[q]]));
        que.push(T(Y[q],X[q],dp[X[q]][Y[q]]));
        while(que.size()){
            int i,j;
            LL p;
            tie(i,j,p)=que.front();
            que.pop();
            dp[i][j]+=p;
            dp[i][j]%=mod;
        }

    }
    LL ret=0;
    for(int i:range(N)){
        for(int j:range(N)){
                dp[i][j]=dp[i][j]*x[Q-last_update[i][j]]%mod;
                if(i>j)ret+=dp[i][j];
        }
    }
    cout<<ret%mod<<endl;
    return 0;
}

Measured memory_bytes: 147968
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
      	int B = sc.nextInt();
      	int C = sc.nextInt();
      	int D = sc.nextInt();
      	if(D>=Math.abs(A-C) ||(D>= Math.abs(A-B) && D>= Math.abs(B-C) ) ){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");      
        }
      
      	
    }
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll f(ll x){
    if(x==1) return 1;
    return x*f(x-1);
}

int main() {
    ll n;  cin >> n;
    vector<vector<char>> alpha(n);
    for(int i=0; i<n; i++){
        string s;   cin >> s;
        for(int j=0; j<s.size(); j++)
            alpha.at(i).push_back(s.at(j));
        sort(alpha.at(i).begin(), alpha.at(i).end());
    }
    
    sort(alpha.begin(), alpha.end());

    ll cnt = 0, i=0;
    vector<ll> x;
    while(i<n-1){
        ll j = i+1, cc=1;
        while(alpha[i]==alpha[j] && j<n){
            cc += 1; j+=1;
        }
        cnt += cc*(cc-1)/2;
        i = j;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 5760
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int a;
  string s;
  cin >> a >> s;
  if(a >= 3200) cout << s << endl;
  else cout << "red" << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

class Program {
    static void Main(string[] args) {
        int a, b;
        Input(out a, out b);
        if(a < b) {
            Console.WriteLine(new string($"{a}"[0], b));
        } else {
            Console.WriteLine(new string($"{b}"[0], a));
        }
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void InputArray<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
}

Measured memory_bytes: 13268
num = int(input())

score = {}
for i in range(num):
    val = input()
    if val in score.keys():
        score[val] += 1
    else:
        score[val] = 1

num = int(input())
for i in range(num):
    val = input()
    if val in score.keys():
        score[val] -= 1

max_val = 0
for result in score.values():
    if max_val < result:
        max_val = result

print(max_val)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define FOR(i, a, b) for(int i=(int)a; i<(int)b; i++)
#define ndl "\n";
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define inrep int t; cin >> t; for(int tc=1; tc<=t; tc++)
#define debug cout << "THIS - PART - HAS - BEEN - REACHED" << ndl;
inline int lcm(int a, int b) {return a/__gcd(a, b)*b;}
inline void out() {cout <<  ndl;}
template <class T> inline void in(T &a) {cin >> a;}
template <class T> inline void in(T &a, T &b) {cin >> a >> b;}
template <class T> inline void out(T a) {cout << a << ndl;}
template <class T> inline void out(T a, T b) {cout << (a) << " " << (b) << ndl;}
typedef long long LL;
typedef unsigned long long ULL;
const int N = 1e6+7;
const int LOGN = log(N) + 2;
const int MOD = 1e9+7;

int main()
{
	ios;
	int x, a, b; in(x, a); in(b);
	if (abs(x-a) < abs(x-b)) {
		out("A");
	}
	else {
		out("B");
	}
	return 0;
}

Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output


def chkprint(*args):
    names = {id(v): k for k, v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg), '???')+' = '+repr(arg) for arg in args))

# Binary converter


def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]

# --------------------------------------------


dp = None


def main():
    N, M, X = li_input()
    A = li_input()

    C = []
    for i in range(N + 1):
        if i in A:
            C.append(1)
        else:
            C.append(0)

    print(min(
        sum(C[:X]),
        sum(C[X+1:])
    ))


main()


Measured memory_bytes: 4628
#[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)*}
    }
}

#[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")
    };
}



fn main() {
    input!(n: usize,);
    let prob = ((n + 1) / 2) as f64 / n as f64;
    println!("{}", prob);
}


Measured memory_bytes: 4352
#include <stdio.h>
#define NUMBER 10000

int main(void){
        int x[NUMBER], y[NUMBER], answer[NUMBER], i, num=0;
        char op;
        for(i=0;i<NUMBER;i++){
                scanf("%d %c %d", &x[i], &op, &y[i]);
                if(op=='+')
                        answer[i]=x[i]+y[i];
                else if(op=='-')
                        answer[i]=x[i]-y[i];
                else if(op=='*')
                        answer[i]=x[i]*y[i];
                else if(op=='/')
                        answer[i]=x[i]/y[i];
                else
                        break;
                num++;
        }
        for(i=0;i<num;i++){
                printf("%d\n", answer[i]);
        }
        return 0;
}


Measured memory_bytes: 2076
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

h,n = mii()
arr = limii()

if sum(arr) >= h:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 77888
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		int sum = 0;
		int i = 0;
		while (sum < n) {
			i++;
			sum += i;
		}
		int ex = sum - n;
		for (int j = 1; j <= i; j++) {
			if (j != ex) {
				System.out.println(j);
			}
		}
	}
}


Measured memory_bytes: 23636
s = gets.chomp

def check_even_str(str)
  if str[0...str.length/2] == str[str.length/2...str.length] then
    return true
  else
    return false
  end
end

i = 1
until check_even_str(s[0...(s.length - i)])
  i += 1
end

puts s.length - i

Measured memory_bytes: 3836
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
}
const int m=2000000;
 vi arr(m);
 int dp[m];
  int memo(int in,int k)
  {
      if(in<1)
      return 9999999999999;
      if(in==1)
      return dp[in]=0;
      if(in==2)
      return dp[in]=abs(arr[1]-arr[2]);
      
      if(dp[in]!=-1)
      return dp[in];
      int ans=9999999999999;
      for(int i=1;i<=k and in-i>=1;i++)
      {
          ans=min(ans,abs(arr[in]-arr[in-i])+memo(in-i,k));
      }
      return dp[in]=ans;
  }
 
int32_t main()
{
    c_p_c();
    //memset(dp,-1,sizeof(dp));
   int n,k;
   cin>>n;
     k=2;
   for(int i=0;i<m;i++)
   {
       dp[i]=-1;
   }
   for(int i=1;i<=n;i++)
   {
       cin>>arr[i];
   }
   int x=memo(n,k);
   cout<<dp[n];
     
    return 0;
}

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

using namespace std;

#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.14159265
#define pb push_back
#define bits(n) __builtin_popcount(n)
#define ll long long int

void solve()
{
    int h,a;
    cin>>h>>a;
    cout<<ceil(h/(double)a);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

#define M 1046527
#define L 14

char H[M][L];

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

long long getk(char search[]){
  long long sum=0;
  long long p=1;
  for(long long i=0;i<strlen(search);i++){
    sum+=p*(getC(search[i]));
    p =p*5;
  }
  return sum;
}

int h1(int k){
  return k%M;
 
}

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

int find(char search[]){
  long long k,h;
  k=getk(search);
  for(long long i=0;;i++){
    h=(h1(k)+i*h2(k))%M;
    if(strcmp(H[h],search)==0)return 1;
    else if(strlen(H[h])==0){
      //strcpy(H[h],search);
      return 0;
    }
  }
  return 0;
}

int insert(char search[]){
  long long k,h;
  k=getk(search);
  for(long long i=0;;i++){
    h=(h1(k)+i*h2(k))%M;
    if(strcmp(H[h],search)==0){
      return 1;
    }
    else if(strlen(H[h])==0){
      strcpy(H[h],search);
      return 0;
    }
  }
  return 0;
}


int main(){
  int n=0,q=0;
  char S[20];
  char search[9];
  int count=0;
  //int key=0;
  for(int i=0;i<M;i++)H[i][0]='\0';
  cin>>n;
  for(int i=0;i<n;i++){
    scanf("%s %s",S,search);
    if(strcmp(S,"insert")==0){
      insert(search);
    }
    else{
      if(find(search)){
	cout<<"yes"<<endl;
      }
      else {
	cout<<"no"<<endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 17552
import math, heapq
from operator import itemgetter as ig
from collections import defaultdict as dd
# 定数
INF = float("inf")
MOD = int(1e9 + 7)
# ヒープ
class heapque:
    def __init__(self, *args):
        self.que = []
        for arg in args:
            self.push(arg)
    def push(self, v):
        heapq.heappush(self.que, v)
    def pop(self):
        return heapq.heappop(self.que)
# 最大公約数 / 最小公倍数
def gcd(v1, v2):
    if v2 == 0:
        return v1
    return gcd(v2, v1 % v2)
def lcm(v1, v2):
    return (v1 // gcd(v1, v2)) * v2
# 二分探索
def bsr(a, v, lo=0, hi=None):
    if hi == None:
        hi = len(a) - 1
    if hi < lo:
        return lo
    mi = (lo + hi) // 2
    if v < a[mi]:
        return bsr(a, v, lo, mi - 1)
    else:
        return bsr(a, v, mi + 1, hi)
# Union-Find木
class uft:
    def __init__(self, n):
        self.height = [1] * n
        self.group = [-1] * n
    def root(self, v):
        if self.group[v] < 0:
            return v
        self.group[v] = self.root(self.group[v])
        return self.group[v]
    def size(self, v):
        return - self.group[self.root(v)]
    def merge(self, v1, v2):
        v1, v2 = self.root(v1), self.root(v2)
        if v1 == v2:
            return
        if self.height[v1] < self.height[v2]:
            self.group[v2] += self.group[v1]
            self.group[v1] = v2
            self.height[v2] = max(self.height[v1] + 1, self.height[v2])
        else:
            self.group[v1] += self.group[v2]
            self.group[v2] = v1
            self.height[v1] = max(self.height[v1] , self.height[v2] + 1)
# グラフ
class graph:
    def __init__(self, n):
        self.n = n
        self.graph = [[] for _ in range(n)]
    def append(self, v1, v2, cost=1):
        self.graph[v1].append((v2, cost))
    # 最短経路：ダイクストラ法(Dijkstra's Algorithm)
    def dks(self, v):
        costs = [INF] * self.n
        costs[v] = 0
        done = [False] * self.n
        heap = heapque((0, v))
        while heap.que:
            c_cost, c_index = heap.pop()
            if done[c_index]:
                continue
            done[c_index] = True
            for n_index, n_cost in self.graph[c_index]:
                if c_cost + n_cost < costs[n_index]:
                    costs[n_index] = c_cost + n_cost
                    heap.push((costs[n_index], n_index))
        return costs

def main():
    N, M = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]

    ab = sorted(AB)
    heap = heapque()
    v, i = 0, 0
    for m in range(1, M + 1):
        while i < N:
            if ab[i][0] <= m:
                heap.push(-ab[i][1])
                i += 1
            else:
                break
        if heap.que:
            v += -heap.pop()
    print(v)

main()


Measured memory_bytes: 32748
n, m = map(int, input().split())
data = [list(map(int, input().split())) for i in range(n)]
count = 0
side = [0] * (m+1)
for i in data:
  total = 0
  for j in i:
    total += j
  data[count].append(total)
  count += 1
for k in data:
  side = [x + y for (x, y) in zip(side, k)]
data.append(side)

for i in data:
  ans = " ".join(map(str, i))
  print(ans)



Measured memory_bytes: 5708
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] x = new int[n];
		int[] y = new int[n];
		for (int i = 0; i < n; i++) {
			String[] sa = br.readLine().split(" ");
			x[i] = Integer.parseInt(sa[0]);
			y[i] = Integer.parseInt(sa[1]);
		}
		br.close();

		zaatu(x);
		zaatu(y);
		Obj[] arr = new Obj[n];
		for (int i = 0; i < n; i++) {
			Obj o = new Obj();
			o.x = x[i];
			o.y = y[i];
			arr[i] = o;
		}
		Arrays.sort(arr, (o1, o2) -> o1.x - o2.x);

		int[] lol = new int[n];
		int[] hil = new int[n];
		BIT bit = new BIT(n);
		for (int i = 0; i < n; i++) {
			lol[i] = bit.sum(arr[i].y);
			hil[i] = i - lol[i];
			bit.add(arr[i].y, 1);
		}

		int[] lor = new int[n];
		int[] hir = new int[n];
		bit = new BIT(n);
		for (int i = 0; i < n; i++) {
			int ri = n - 1 - i;
			lor[ri] = bit.sum(arr[ri].y);
			hir[ri] = i - lor[ri];
			bit.add(arr[ri].y, 1);
		}

		int mod = 998244353;
		long ans = n * power(2, n - 1, mod) % mod;
		for (int i = 0; i < n; i++) {
			long val1 = power(2, lol[i], mod);
			long val2 = power(2, hil[i], mod);
			long val3 = power(2, lor[i], mod);
			long val4 = power(2, hir[i], mod);
			long val11 = (val1 - 1 + mod) % mod;
			long val21 = (val2 - 1 + mod) % mod;
			long val31 = (val3 - 1 + mod) % mod;
			long val41 = (val4 - 1 + mod) % mod;
			ans += val11 * val21 % mod * val31 % mod * val41 % mod;
			ans += val11 * val21 % mod * val31 % mod;
			ans += val11 * val21 % mod * val41 % mod;
			ans += val11 * val31 % mod * val41 % mod;
			ans += val21 * val31 % mod * val41 % mod;
			ans += val11 * val41 % mod;
			ans += val21 * val31 % mod;
			ans %= mod;
		}
		System.out.println(ans);
	}

	static long power(long x, long n, int m) {
		if (n == 0) {
			return 1;
		}
		long val = power(x, n / 2, m);
		val = val * val % m;
		if (n % 2 == 1) {
			val = val * x % m;
		}
		return val;
	}

	static void zaatu(int[] a) {
		TreeMap<Integer, Integer> map = new TreeMap<>();
		for (int i = 0; i < a.length; i++) {
			map.put(a[i], null);
		}
		Integer[] arr = map.keySet().toArray(new Integer[0]);
		int cnt = 0;
		for (Integer i : arr) {
			cnt++;
			map.put(i, cnt);
		}
		for (int i = 0; i < a.length; i++) {
			a[i] = map.get(a[i]);
		}
	}

	static class BIT {
		int n;
		int[] arr;

		public BIT(int n) {
			this.n = n;
			arr = new int[n + 1];
		}

		void add(int idx, int val) {
			for (int i = idx; i <= n; i += i & -i) {
				arr[i] += val;
			}
		}

		int sum(int idx) {
			int sum = 0;
			for (int i = idx; i > 0; i -= i & -i) {
				sum += arr[i];
			}
			return sum;
		}
	}

	static class Obj {
		int x, y;
	}
}


Measured memory_bytes: 86852
import java.util.*;
import java.math.*;
class Main{
static BigInteger gcd(BigInteger a,BigInteger b){
while(!(a.equals(BigInteger.ZERO))){
b=b.mod(a);
BigInteger c=new BigInteger(a.toString());
a=new BigInteger(b.toString());
b=new BigInteger(c.toString());
}
return b;}
static BigInteger lcm(BigInteger a,BigInteger b){return a.multiply(b).divide(gcd(a,b));}
public static void main(String args[]){
Scanner s=new Scanner(System.in);
while(true){
int a=s.nextInt();
if(a==0)System.exit(0);
BigInteger bi[]=new BigInteger[a];
for(int i=0;i<a;i++)bi[i]=BigInteger.ONE;
for(int i=0;i<a;i++){
BigInteger b=s.nextBigInteger();
BigInteger c=s.nextBigInteger();
bi[i]=bi[i].multiply(b);
for(int j=0;j<a;j++)
if(i!=j)bi[j]=bi[j].multiply(c);
}
BigInteger res=BigInteger.ONE;
for(int i=0;i<a;i++)res=lcm(res,bi[i]);
for(int i=0;i<a;i++)System.out.println(res.divide(bi[i]).toString());
}}}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
bool dp[81][81][12801]={0};
int main(){
    int h,w,A[80][80],B[80][80];
    cin>>h>>w;
    rep(i,h)rep(j,w) cin>>A[i][j];
    rep(i,h)rep(j,w) cin>>B[i][j];
    rep(i,h)rep(j,w){
        if(!i&&!j){
            dp[i][j][abs(A[i][j]-B[i][j])]=1;
            dp[i][j][abs(-A[i][j]+B[i][j])]=1;
        }
        if(i){
            rep(k,12801)if(dp[i-1][j][k]){
                if(abs(k+A[i][j]-B[i][j])<=12800) dp[i][j][k+abs(A[i][j]-B[i][j])]=1;
                if(abs(k-A[i][j]+B[i][j])<=12800) dp[i][j][abs(k-abs(A[i][j]-B[i][j]))]=1;
            }
        }
        if(j){
            rep(k,12801)if(dp[i][j-1][k]){
                if(abs(k+A[i][j]-B[i][j])<=12800) dp[i][j][k+abs(A[i][j]-B[i][j])]=1;
                if(abs(k-A[i][j]+B[i][j])<=12800) dp[i][j][abs(k-abs(A[i][j]-B[i][j]))]=1;
            }
        }
    }
    int ans=6400;
    rep(i,12801) if(dp[h-1][w-1][i]) ans=min(ans,i);
    cout<<ans<<"\n";
}


Measured memory_bytes: 81280
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
	long double t,n,i,j;
    t=1;
//	cin >> t;
    while(t--)
    {
        cin >> n >> i;
        ll tp = i*n;
        cout <<  tp;        
    }
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

    int d = __gcd(X, 360);
    cout << 360 / d << endl;
}

Measured memory_bytes: 3596
#include<vector>
#include<tuple>
#include<limits>
class Bellman_Ford{
private:
    using size_type=std::vector<long long>::size_type;
public:
    using edge_vec=std::vector<std::tuple<size_type,size_type,long long>>;//edge={{from,to,cost}}
    static /*inline*/ constexpr auto inf=std::numeric_limits<long long>::max();
    static /*inline*/ constexpr auto minf=std::numeric_limits<long long>::min();
    static std::vector<long long>get_min_cost(const edge_vec&edge,size_type node_cnt,size_type start=0)
    {
        std::vector<long long>ret(node_cnt,inf);
        ret[start]=0;
        bool is_updated=false;
        for(size_type i=0;i<ret.size();++i){
            for(auto e:edge){
                size_type from=std::get<0>(e),to=std::get<1>(e);
                long long cost=std::get<2>(e);
                if(ret[from]!=inf&&ret[to]>ret[from]+cost){
                    ret[to]=ret[from]+cost;
                    is_updated=true;
                }
            }
            if(!is_updated)break;
        }
        if(is_updated){
            for(auto e:edge){
                size_type from=std::get<0>(e),to=std::get<1>(e);
                long long cost=std::get<2>(e);
                if(ret[from]==minf||ret[from]!=inf&&ret[to]>ret[from]+cost){
                    ret[to]=minf;
                }
            }
        }
        return ret;
    }
};

#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T=ll>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
int main()
{
    ll n=in(),m=in();
    Bellman_Ford::edge_vec e(m);
    for(ll i=0;i<m;++i){
        ll a=in(),b=in(),c=in();
        e[i]=make_tuple(a-1,b-1,-c);
    }
    auto dist=Bellman_Ford::get_min_cost(e,n);
    if(dist[n-1]!=Bellman_Ford::minf){
        cout<<-dist[n-1]<<endl;
    }else{
        cout<<"inf"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn=100+10;
const int inf=1<<30;
int a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    int sum=0;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),sum+=a[i];
    int ans1=0,ans=inf; 
    for(int j=-100;j<=100;j++)
	{
		ans1=0;
		for(int i=1;i<=n;i++)
		{
			int k=a[i]-j;
			ans1+=k*k;
		}
		ans=min(ans,ans1);
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,ans=0;
	cin>>n;
	bool k[n]={};
	for(int i=0; i<n; i++){k[i]=true;}
	
	int x;
	cin>>x;
	for(int i=0; i<x; i++){
		int a;cin>>a;
		k[a-1]=false;
	}
	
	cin>>x;
	for(int i=0; i<x; i++){
		int a;cin>>a;
		k[a-1]=true;
	}
	
	cin>>x;
	for(int i=0; i<x; i++){
		int a;cin>>a;
		if(k[a-1]==true) ans++;
	}
	
	cout<<ans<<endl;
	
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll sum=0;
    sum+=(n/(a+b))*a;
    n-=(n/(a+b))*(a+b);
    if(n<a)sum+=n;
    else sum+= a;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	void run() {
		try (Scanner sc = new Scanner(System.in)) {
			String s1 = sc.next().toUpperCase().substring(0, 1);
			String s2 = sc.next().toUpperCase().substring(0, 1);
			String s3 = sc.next().toUpperCase().substring(0, 1);
			System.out.println(s1 + s2 + s3);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


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

int main() {
	string s;
	cin >> s;
	int ans = 0;
	int len = 0;
	
	for(char c : s) {
		if(c == 'R') {
			len++;
			ans = max(ans,len);
		} else len = 0;
	}
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 3624
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#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>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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


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

int lcm(int a, int b)
{
	return a * b / gcd(a, b);
}

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	set<ll> st;
	rep(i, n) {
		ll x;
		cin >> x;
		//cin >> a[i];
		st.insert(x);
	}
	if (n == st.size()) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 11136
def MergeSort(arr):
    if len(arr) <= 1:
        return arr
    mid = len(arr) // 2
    left = arr[:mid]
    right = arr[mid:]
    left = MergeSort(left)
    right = MergeSort(right)
    return MergeArray(left, right)

def MergeArray(left, right):
    merged = []
    li, ri = 0, 0
    while li < len(left) and ri < len(right):
        if left[li] > right[ri]:
            merged.append(left[li])
            li += 1
        else:
            merged.append(right[ri])
            ri += 1
    if li < len(left):
        merged.extend(left[li:])
    elif ri < len(right):
        merged.extend(right[ri:])
    return merged

def solve():
    X, Y, Z, K = [int(_) for _ in raw_input().split()]
    A = [int(_) for _ in raw_input().split()]
    B = [int(_) for _ in raw_input().split()]
    C = [int(_) for _ in raw_input().split()]
    A = MergeSort(A)[:K]
    B = MergeSort(B)[:K]
    C = MergeSort(C)[:K]
    lB = len(B)
    lC = len(C)
    sumAB = []
    for i in range(lB):
        tmpA = [ele + B[i] for ele in A]
        sumAB = MergeArray(sumAB, tmpA)[:K]
    sumABC = []
    for i in range(lC):
        tmpAB = [ele + C[i] for ele in sumAB]
        sumABC = MergeArray(sumABC, tmpAB)[:K]
    for i in range(K):
        print sumABC[i]

if __name__ == '__main__':
    solve()


Measured memory_bytes: 40604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

class FordFulkerson
{
public:
    FordFulkerson(int n) : _n(n), _graph(n), _used(n, false) {}

    void add_edge(int from, int to, ll cap)
    {
        _graph[from].emplace_back(to, cap, (int)_graph[to].size());
        _graph[to].emplace_back(from, 0, (int)_graph[from].size() - 1);
    }

    ll operator()(int s, int t)
    {
        ll flow = 0;
        while (true) {
            fill(_used.begin(), _used.end(), false);
            ll f = dfs(s, t, linf);
            if (f == 0) return flow;
            flow += f;
        }
    }

private:
    struct edge
    {
        int to; ll cap; int rev;
        edge(int to, ll cap, int rev) : to(to), cap(cap), rev(rev) {}
    };

    int _n;
    vector<vector<edge>> _graph;
    vector<bool> _used;

    ll dfs(int v, int t, ll f)
    {
        if (v == t) return f;
        _used[v] = true;
        for (auto &e: _graph[v]) {
            if (!_used[e.to] && e.cap > 0) {
                ll d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    _graph[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
};

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

    int V, E; cin >> V >> E;
    FordFulkerson flow(V);
    for (int i = 0; i < E; i++) {
        int u, v, c; cin >> u >> v >> c;
        flow.add_edge(u, v, c);
    }
    cout << flow(0, V - 1) << endl;
    return 0;
}



Measured memory_bytes: 3240
#include<bits/stdc++.h>
#include<stdio.h>
#define ll  long long
#define M 300002
#define N 1000000000000000003
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n,v;
    cin>>n>>v;
    ll arr[200004]={0};ll var[200003]={0};
    for(ll i=1;i<=n;i++)
    {
        cin>>arr[i];
        var[arr[i]]=1;
    }
    sort(arr,arr+n);
    
    for(ll i=arr[1];i<=v;i++)
    {
        if(var[i]==1)
        {continue;
        }
       
            for(ll j=1;j<=n;j++)
            {
                if(i-arr[j]>=0)
                {
                if(var[i-arr[j]]==0)
                {
                    var[i]=1;break;
                }
                }
            }
        
    }
 
    if(var[v]==1) cout<<"First";
    else cout<<"Second";
    return 0;
}


Measured memory_bytes: 3328
from collections import deque

h, w, k = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())
x1 -= 1
x2 -= 1
y1 -= 1
y2 -= 1
# C[h][w]
C = [list(input()) for _ in range(h)]

dist = [[10 ** 10] * w for _ in range(h)]

dist[x1][y1] = 0
que = deque([])
que.append((x1, y1))

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

while que:
    a, b = que.popleft()
    d = dist[a][b]
    if a == x2 and b == y2:
        print(dist[x2][y2])
        exit()
    for i in range(4):
        cx = a + dx[i]
        cy = b + dy[i]
        if cx < 0 or cx >= h or cy < 0 or cy >= w:
            continue
        if C[cx][cy] == "@":
            continue
        for j in range(1, k + 1):
            nx = a + dx[i] * j
            ny = b + dy[i] * j
            if nx < 0 or nx >= h or ny < 0 or ny >= w:
                break
            if C[nx][ny] == "@":
                break
            if dist[nx][ny] < d + 1:
                break
            if dist[nx][ny] == 10 ** 10:
                dist[nx][ny] = d + 1
                que.append((nx, ny))
print(-1)


Measured memory_bytes: 134460
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

  	Int a, b; cin >> a >> b;
    cout << ((a*b)%2 == 0 ? "Even" : "Odd") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
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 long long INF = 1LL << 60;
typedef pair<int, int> P;

int main() {
    int N; cin >> N;
    cout << N * N << endl;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
   int n;cin>>n;
   ll L[100];
   L[0] = 2;
   L[1] = 1;
   for(int i = 2;i<100;i++){
       L[i] = L[i-1] + L[i-2];
   }

   cout<<L[n]<<endl;
    return 0;
}


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

int main() {
  int a,b;
  cin>>a>>b;
  if(a<b){
    int i=0;
     while(i<b){cout<<a;
    i++;
               }
  }
  
  else {int i=0;
     while(i<a){cout<<b;
    i++;
               }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> P;
bool check[105][2];
int next[105][2];
int ab[105][2];
long long n;
main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++){
      cin>>ab[i][0];
      next[i][0]=i;
    }
    for(int i=0;i<n;i++){
      cin>>ab[i][1];
      next[i][1]=i;
    }
    long long before[2];
    before[0]=before[1]=-1;
    for(int i=n-1;i>=0;i--){
      for(int j=0;j<2;j++){
	if(ab[i][j]==1){
	  if(before[j]==-1){
	    before[j]=i;
	  }
	  else{
	    next[i][j]=before[j];
	  }
	}
	else{
	  before[j]=-1;
	}
      }
    }    
    for(int i=0;i<n;i++){
      for(int j=0;j<2;j++){
	if(ab[i][j]==2){
	  next[i][j]=before[j];
	}
	else{
	  before[j]=i;
	}
      }
    }
    /*
    for(int i=n-1;i>=0;i--){
      printf("%4d | %4d\n",next[i][0],next[i][1]);
    }
    */
    priority_queue<P,vector<P>,greater<P> > que;
    int ans=10000;
    for(int i=0;i<2;i++){
      memset(check,0,sizeof(check));
      que.push(P(0,ii(i,next[0][i])));
      check[next[0][i]][i]=true;
      while(!que.empty()){
	int nowcnt=que.top().F;
	int lr=que.top().S.F;
	int floar=que.top().S.S;
	que.pop();
	if(floar==n-1){
	  ans=min(ans,nowcnt);
	  break;
	}
	for(int i=0;i<3&&floar+i<n;i++){
	  long long nf=floar+i;
	  long long nlr=(lr+1)%2;
	  while(next[nf][nlr]!=nf){
	    nf=next[nf][nlr];
	  }
	  if(check[nf][nlr]==false){
	    check[nf][nlr]=true;
	    que.push(P(nowcnt+1,ii(nlr,nf)));
	  }
	}
      }
    }
    if(ans==10000) cout<<"NA"<<endl;
    else cout<<ans<<endl;
  }
}

Measured memory_bytes: 3068
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] L = new int[N];
		int max = 0;
		int sum = 0;

		for(int i=0; i<N; i++){
			L[i] = sc.nextInt();
			if(i>0){
				if(L[i] >= L[max]){
					sum += L[max];
					max = i;
				}else{
					sum += L[i];
				}
			}
		}
		if(L[max]<sum){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35576
n,k=map(int,input().split())
s=input()
s=s+"w"
lists0=[]
lists1=[] 
count=0
for i in range(n):
    if s[i]!=s[i+1] and s[i]=="0":
        lists0.append(i-count)
        count=i
        
    elif s[i]!=s[i+1] and s[i]=="1":
        lists1.append(i-count)
        count=i

if s[0]=="1":
    lists1[0]+=1
elif s[0]=="0":
    lists0[0]+=1     
#下準備の完成
if s[0]=="1" and s[-2]=="1":
    #do nothing special
    if k>=len(lists0):
        print(n)
    elif k<len(lists0):
        big=0
        ans=sum(lists1[:k+1])+sum(lists0[:k])
        for i in range(len(lists0)-k):
            ans1=ans+lists1[k+1+i]+lists0[k+i]-lists1[i]-lists0[i]
            big=max(big,max(ans,ans1))
            ans=ans1
        print(big)
       
        
elif s[0]=="1" and s[-2]=="0":
    # 最後にlists1の方に0を挿入する
    lists1.append(0)

    if k>=len(lists0):
        print(n)
    elif k<len(lists0):
        big=0
        ans=sum(lists1[:k+1])+sum(lists0[:k])
        for i in range(len(lists0)-k):
            ans1=ans+lists1[k+1+i]+lists0[k+i]-lists1[i]-lists0[i]
            big=max(max(ans,ans1),big)
            ans=ans1
        print(big)
    
elif s[0]=="0" and s[-2]=="1":
    #さいしょのlist1の方に0を挿入する
    lists1.insert(0,0)

    if k>=len(lists0):
        print(n)
    elif k<len(lists0):
        big=0
        ans=sum(lists1[:k+1])+sum(lists0[:k])
        for i in range(len(lists0)-k):
            ans1=ans+lists1[k+1+i]+lists0[k+i]-lists1[i]-lists0[i]
            big=max(big,max(ans,ans1))
            ans=ans1
        print(big)    
elif s[0]=="0" and s[-2]=="0":
    #最初と最後にlist1の方に0を挿入する
    lists1.insert(0,0)
    lists1.append(0)

    if k>=len(lists0):
        print(n)
    elif k<len(lists0):            
        big=0
        ans=sum(lists1[:k+1])+sum(lists0[:k])
        for i in range(len(lists0)-k):
            ans1=ans+lists1[k+1+i]+lists0[k+i]-lists1[i]-lists0[i]
            big=max(big,max(ans,ans1))
            ans=ans1
        print(big)        
    

Measured memory_bytes: 4604
#include <iostream>

using namespace std;

int A[2][101];

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < 2; i++){
        for(int j = 1; j <= N; j++){
            cin >> A[i][j];
            A[i][j] += A[i][j-1];
        }
    }

    int ans = 0;
    for(int i = 1; i <= N; i++){
        ans = max(ans, A[0][i] + (A[1][N] - A[1][i-1]));
    }
    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
int gcd(int a, int b){
	if(a%b==0)return b;
	return gcd(b,a%b);
}
int main(){
	cin>>N;
	int tmp=360/gcd(N,360);
	cout<<tmp<<'\n';
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rgt register
#define rint rgt int
#define LL long long
#define rll rgt LL
#define inf 0x7f7f7f7f
using namespace std;
template<class K>inline bool cmax(K&a,const K&b){return(a<b)?a=b,1:0;}
template<class K>inline bool cmin(K&a,const K&b){return(a>b)?a=b,1:0;}
inline int read() {
	rint s=0;
	rgt char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) s=(s<<1)+(s<<3)+c-'0',c=getchar();
	return s;
}
int H,n,sum;
int main()
{
	rint i,j;
	H=read(),n=read();
	for(i=1;i<=n;i++) sum+=read();
	printf("%s",sum>=H?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {


	public static void main(String[] args) {

		long ans = 0;
//		double ans = 0.0;
//		int ans = 0;
//		String ans = "";

		Scanner sc = new Scanner(System.in);
//		double waru = 1000000007;


		long n = sc.nextLong();
//		long m = sc.nextLong();
//		long k = sc.nextLong();

//		int n = sc.nextInt();
//		int m = sc.nextInt();
//		int k = sc.nextInt();
//		int v = sc.nextInt();
//		String s = sc.next();


//		String string = sc.next();
//		StringBuilder s = new StringBuilder(string);

//		String[] strArray = string.split("");

		boolean f = false;

//		String[] s = new String[n];

//		int[] a = new int[n];
//		int[] b = new int[n];
//		long[] a = new long[n];
//		int[][] a = new int[n][m];

//		ArrayList<Long> list = new ArrayList<>();

//		for (int i = 0; i < n; i++) {
//			a[i]= sc.nextInt();
//		}
//		for (int i = 0; i < h; i++) {
//			for(int j = 0; j < w; j++) {
//				a[i][j] = sc.nextInt();
//			}
//		}

		long tmp = 0;
		long tmp2 = 0;
		if(n == 0) {
			System.out.println(ans);
			sc.close();
			return;
		}

		tmp2 = n/500;
		ans += tmp2*1000;
		tmp = n%500;
		tmp2 = tmp/5;
		ans += tmp2*5;

		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 23892
h,w=map(int,input().split())
a=[]
b=[]
for i in range(h):
   n=input()
   if n.count(".")<w:a+=[n]
for i in range(w):
   if [I[i] for I in a].count(".")==len(a):
      b+=[i]
for i in range(len(a)):
   print("".join([a[i][I] for I in range(w) if I not in b]))

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#define int long long
using namespace std;
#define N 100005

int n, l[N], x, tmp;
int ans = 1;

signed main(){
	cin >> n >> x;
	for(int i = 1; i <= n; ++i){
		int a;
		cin >> a;
		tmp += a;
		if(tmp <= x) ++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, l, i, j, k;
	cin >> n >> l;
	vector<long long> a(n);
	bool found = false;
	for (i = 0; i < n; i++) cin >> a[i]; 
	for (i = 1; i < n; i++) {
		if (a[i] + a[i - 1] >= l) {
			found = true;
			cout << "Possible\n";

			for (j = 1; j < i; j++) cout << j << "\n";
			for (j = n - 1; j >= i + 1; j--) cout << j << "\n";
			cout << i << "\n";

			break;
		}
	}
	if (!found) cout << "Impossible\n";


	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define FOR(x,n) for(int x = 0; x < n; x++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())
using namespace std;
typedef long long ll;

int main() {
  int A, B; cin >> A >> B;
  if(abs(A) == abs(B))
    cout << (A != B) << "\n";
  else if(abs(A) < abs(B) && A >= 0)
    cout << abs(B) - abs(A) + (B < 0) << "\n";
  else if(abs(A) < abs(B) && A < 0)
    cout << 1 + abs(B) - abs(A) + (B < 0) << "\n";
  else if(abs(A) > abs(B) && A >= 0)
    cout << 1 + abs(A) - abs(B) + (B > 0) << "\n";
  else
    cout << abs(A) - abs(B) + (B > 0) << "\n";
}

Measured memory_bytes: 256
def Fib(n):
  a, b = 1, 1
  if n == 0:
  	return a
  elif n == 1:
    return b
  else:
    for i in range(n-2):
      a, b = b, a + b
    return b

mod = 1000000007
def mul(a, b):
  return ((a % mod) * (b % mod)) % mod


N, M = map(int, input().split())
if M != 0:
  a = int(input())
  ret = mul(1, Fib(a))
  pre_a = a

for i in range(M-1):
  a = int(input())
  if a - pre_a <= 1:
    ret = 0
    break
  else:
    num_step = a - pre_a - 1
    ret = mul(ret, Fib(num_step))
  pre_a = a
    
if M != 0:
  num_step = N - a
  ret = mul(ret, Fib(num_step))
else:
  ret = mul(1, Fib(N+1))
print(ret)


Measured memory_bytes: 3064