akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int N;
    cin >> N;
    vector< pair<int,int> > vp;
    for(int i=0;i<N;i++){
        int index=i+1;
        int value;
        cin >> value;
        vp.push_back(make_pair(value,index));
    }
    sort(vp.begin(),vp.end());
    for(int i=0;i<N;i++){
        cout << vp[i].second << " ";
    }
    cout << endl;
    
}

Measured memory_bytes: 1780
#include <iostream>
#define REP(i,n) for(int i=0;i<n;++i)
using namespace std;
const int MAX_N = 200000;

int main() {
  int n, R[MAX_N];
  cin >> n;
  REP(i, n) cin >> R[i];
  int maxv = R[1] - R[0];
  int minv = R[0];

  REP(i, n) {
    if (i == 0) continue;
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }
  cout << maxv << endl;

  return 0;
}

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

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

	long long num[n];
	for(int i=0;i<n;i++){
		cin >> num[i];
	}

	//min
	long long min = 1000001;
	for(int i=0;i<n;i++){
		if(min > num[i])
			min = num[i];
	}

	//max
	long long max =-1000001;
	for(int i=0;i<n;i++){
		if(max < num[i])
			max = num[i];
	}


	//sum
	long long sum = 0;
	for(int i=0;i<n;i++){
		sum = sum + num[i];
	}




	cout << min << " " << max << " " << sum << endl;

	return 0; 
}

Measured memory_bytes: 3148
using System;
using System.Linq;

class Program
{
    static readonly long INF = 100100100100;
    static void Main(string[] args)
    {
        long n = long.Parse(Console.ReadLine());
        long count = 0;
        if (IsPrime(n))
        {
            Console.WriteLine(1);
            return;
        }
        for (long i = 2; i * i < n; i++)
        {
            if (!IsPrime(i)) continue;
            if (n % i == 0)
            {
                n /= i;
                long x = 1;
                for (long j = 2; j < INF; j++)
                {
                    if (n % i != 0) break;
                    n /= i;
                    x++;
                }
                for (long j = 1; j < INF; j++)
                {
                    x -= j;
                    if (x < 0) break;
                    count++;
                }
            }
        }
        if (n > 1) count++;
        Console.WriteLine(count);
    }

    static bool IsPrime(long n)
    {
        if (n == 1) return false;
        for (long i = 2; i * i <= n; i++)
            if (n % i == 0) return false;

        return true;
    }
}

Measured memory_bytes: 27532
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, a, b)    for (int i(a); i <= (b); ++i)
#define dec(i, a, b)    for (int i(a); i >= (b); --i)
#define MP      make_pair
#define fi      first
#define se      second
 
 
typedef long long LL;
 
const int N = 1e3 + 5;
 
int a[N], b[N];
int n, m, c, fg;
char s[45];
 
 
int main(){
 
    scanf("%d", &n);
    c = 0;
 
    rep(i, 1, n){
        scanf("%d%d", a + i, b + i);
        if ((a[i] + b[i]) & 1) ++c;
        else --c;
    }
 
    if (abs(c) != n) return 0 * puts("-1");
 
    m = 31 + (c < 0);
 
    printf("%d\n", m);
    rep(i, 0, 30) printf("%d ", 1 << i);
    if (c < 0) putchar(49);
    putchar(10);
 
    rep(i, 1, n){
        int x = a[i], y = b[i];
        if (c < 0) s[31] = 'R', --x;
        fg = 0;
        dec(j, 30, 0){
            if (abs(x) < abs(y)) swap(x, y), fg ^= 1;
            if (x > 0) x -= 1 << j, s[j] = fg ? 'U' : 'R';
            else x += 1 << j, s[j] = fg ? 'D' : 'L';
        }
 
        puts(s);
    }
 
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

class UnionFind(object):

    def __init__(self, n):
        self.table = [-1] * N

    def find(self, x):
        parent = self.table[x] 
        if parent < 0:
            return x
        else:
            root = self.find(parent)
            self.table[x] = root
            return root

    def union(self, x1, x2):
        root1 = self.find(x1)
        root2 = self.find(x2)
        if root1 < root2:
            self.table[root1] += self.table[root2]
            self.table[root2] = root1
        else:
            self.table[root2] += self.table[root1]
            self.table[root1] = root2

N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
xy = [[int(x) for x in input().split()] for i in range(M)]

def solve(N, M, A, xy):

    uf = UnionFind(N)
    for x, y in xy:
        uf.union(x, y)

    groups = defaultdict(list)
    for i in range(N):
        groups[uf.find(i)].append(A[i])

    groups = [sorted(g, reverse=True) for g in groups.values()]

    if len(groups) == 1:
        return 0

    r = 0

    xs = []
    for group in groups:
        r += group.pop()
        xs += group

    if len(groups) == 2:
        return r

    if len(groups) - 2 > len(xs):
        return "Impossible"

    xs.sort()
    r += sum(xs[:len(groups) - 2])

    return r

print(solve(N, M, A, xy))


Measured memory_bytes: 40504
def bubbleSort(A,N):  # N個の要素を含む0-オリジンの配列A
    flag = 1
    i = 0  # 未ソート部分列の先頭インデックス
    while flag == 1:
        flag = 0
        for j in range(N-1,0,-1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                flag = 1
                i += 1
    print(*A)
    print(i)

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

bubbleSort(A,N)


Measured memory_bytes: 5612
// B - AcCepted
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> s;
  if (s[0] != 'A')
  {
    cout << "WA" << endl;
    return 0;
  }
  else
  {
    repe(i, 2, s.size() - 2)
    {
      if (s[i] == 'C')
      {
        count++;
      }
    }
    if (count != 1)
    {
      cout << "WA" << endl;
      return 0;
    }
    else
    {
      rep(i, 0, s.size())
      {
        if (s[i] != 'C' && s[i] != 'A')
        {
          if (isupper(s[i]))
          {
            cout << "WA" << endl;
            return 0;
          }
        }
      }
    }
    cout << "AC" << endl;
    return 0;
  }
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << min(a,b) + min(c,d) << endl;
    return 0;
}


Measured memory_bytes: 256
m=10**9+7
f=lambda x:max(x,0)
r=range
for _ in r(int(input())):
	x,y=sorted(map(int,input().split()))
	s=-1
	i=j=1
	while j<=x and i+j<=y:i,j,s=j,i+j,s+1
	if x==1 or y<3:print(1,x*y%m)
	else:
		a=f((y-j)//i+1)+f((x-j)//i+1)
		i=j=1
		for c in r(s):
			k,l=j,i+j*2
			for _ in r(s-c):k,l=l,k+l
			if x>=k:a+=f((y-l)//k+1)
			if y>=k:a+=f((x-l)//k+1)
			i,j=j,i+j
		print(s+1,a%m)

Measured memory_bytes: 79484
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)

int main(){
    string a,op,b;
    
    while(1){
        cin>>a>>op>>b;
        if(op=="?") break;
        
        if(op=="+"){
            cout<<stoi(a)+stoi(b)<<endl;
        }else if(op=="-"){
            cout<<stoi(a)-stoi(b)<<endl;
        }else if(op=="*"){
            cout<<stoi(a)*stoi(b)<<endl;
        }else{
            cout<<stoi(a)/stoi(b)<<endl;
        }
    }
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using llint = long long int;
using namespace std;

int main() {
    fastIO;
    int n;
    cin >> n;
    vector<int> s(n);
    rep(i, n) cin >> s.at(i);

    llint sum = 0;
    llint step = s.front();
    for (size_t i = 1; i < s.size(); i++) {
        llint current = s.at(i);
        if (step > current) {
            sum += step - current;
        }
        step = max(step, current);
    }
    cout << sum << endl;
}

Measured memory_bytes: 3952
Q, H, S, D = map(int, input().split())
N = int(input())
q = 8*Q
h = 4*H
s = 2*S
if N%2 == 0:
    print(min(q,h,s,D)*(N//2))
else:
    print(min(q,h,s,D)*(N//2) + min(4*Q,2*H,S))

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

int main()
{
  int n;
  int f = 0,s = 0;
  for(int i=0;i<3;i++)
  {
    cin>>n;
    if(n==5)
    {
      f++;
    }
    if(n==7)
    {
      s++;
    }
  }
  if(f==2&&s==1)
  {
    cout<<"YES";
  }
  else
  {
    cout<<"NO";
  }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
char a[105][105];
int c,d,b[105][105];
int main()
{
  int x,y,i,j;	
  cin>>x>>y;
  for(i=0;i<x;i++)
    cin>>a[i];
  for(i=0;i<x;i++)
    for(int j=0;j<y;j++)
      if(a[i][j]=='#')
      {
  b[i][j]++;
  b[i][j+1]++;
  b[i][j+2]++;
  b[i+1][j]++;
  b[i+1][j+1]++;
  b[i+1][j+2]++;
  b[i+2][j]++;
  b[i+2][j+1]++;
  b[i+2][j+2]++;
    }
  for(i=0;i<x;i++)
  {
    for(j=0;j<y;j++)
        if(a[i][j]=='#') 
		  cout<<'#';
      else 
	    cout<<b[i+1][j+1];
      cout<<endl;
  }
  return 0;    
}

Measured memory_bytes: 764
#include<string>
#include<cstdio>
#include<cctype>
#include<iostream>
#include <algorithm>
#include<cmath>
#include<queue>
using namespace std;

int main(){
        int ti[8]={0}, ans[5]={0},s,ss;
        for(int i=0;i<3;i++){
        cin >>ti[1]>>ti[2]>>ti[3]>>ti[4]>>ti[5]>>ti[6];
        s=ti[1]*3600+ti[2]*60+ti[3];
        ss=ti[4]*3600+ti[5]*60+ti[6];
        ans[4]=ss-s;
        ans[1]=ans[4]/3600;
        ans[4]%=3600;
        ans[2]=ans[4]/60;
        ans[4]%=60;
        ans[3]=ans[4];
        cout <<ans[1]<<" "<<ans[2]<<" "<<ans[3]<<endl;
        }
    return 0;
}

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

using namespace std;

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

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cerr << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

ll s[10][10];
ll p[10];

ll N, M;
ll k;
ll c;

bool judge(string S) {
  for (ll den = 0; den < M; den++) {
    ll cOn = 0;

    for (ll swi = 0; swi < 10; swi++) {
      ll kswitch = s[den][swi];
      if (kswitch == 0)
        break;

      if (S[kswitch] == '1') {
        cOn++;
      }
    }

    // if (cOn == 0) {
    //   return false;
    // }

    if (cOn % 2 != p[den]) {
      cerr << " -> off" << endl;
      return false;
    }
  }

  cerr << " -> on" << endl;
  return true;
}

void dfs(ll i, string S) {
  if (N <= i) {

    if (judge(S)) {
      c++;
    }
    return;
  }

  dfs(i + 1, S + "0");
  dfs(i + 1, S + "1");
}

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

  cin >> N >> M;

  for (ll i = 0; i < M; i++) {
    cin >> k;

    for (ll j = 0; j < k; j++) {
      cin >> s[i][j];
    }
  }

  for (ll i = 0; i < M; i++) {
    cin >> p[i];
  }

  dfs(0, "-");

  cout << c << endl;

  return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
import numpy as np

n, k = map(int, input().split())
p = np.array(list(map(int, input().split())), dtype=np.int64)

p = (1 + p) / 2
p = [0] + list(accumulate(p))
ans = 0
for i in range(n - k + 1):
    ans = max(ans, p[i + k] - p[i])
print(ans)


Measured memory_bytes: 33996
N, K = map(int, input().split())

MOD = 10 ** 9 + 7

count = 0	
for i in range(K, N + 2):
    count += (((2 * N - i + 1) - (i - 1)) * i // 2 + 1) % MOD
    
count %= MOD
print(count)

Measured memory_bytes: 9176
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main(){
  int n;
  while(cin >> n, n){
    int seq[30];
    
    for(int i = 0 ; i < n ; i++){
      cin >> seq[i];
    }
    
    int r = 32;
    int i = 0;
    while(1){
      if(r <= 0) break;
      r -= (r-1)%5;
      cout << r << endl;
      r -= seq[i];
      if(r <= 0) r = 0;
      cout << r << endl;
      i++;
      if(i == n) i = 0;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int n;
  cin >> n;
  set<string> s;
  for(int i = 0;i<n;i++)
  {
      string t;
      cin >> t;
      s.insert(t);
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 19176
#include<iostream>

using namespace std;

const long long sb = 1e18;

int main()
{
  long long n, a[100005], ans = 1, flag = 0;
  cin >> n;
  for(int i = 0; i < n; i++)
  {
      cin >> a[i];
      if(a[i] == 0)
          flag = 1;
  }
  if(flag)
  {
      cout << 0 << endl;
      return 0;
  }
  for(int i = 0; i < n; i++)
  {
    if(ans > sb/a[i])
    {
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
  }
  cout << ans << endl;
  return 0;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (300006)
ll ans;
int main(){
	string A;
	cin>>A;
	string B;
	cin>>B;
	FOR(i,0,siz(A)-1)ans += A[i] != B[i];
	cout<<ans<<'\n';
}


Measured memory_bytes: 3924
import collections 
n,k = map(int, raw_input().split(' '))

cc=  collections.Counter()
for ii in range(1, n+1):
	cc[ii % k] +=1

r = 0
for ii in cc:
	if (- 2*ii) % k == 0:
		r += cc[ii] * ((cc[(k - ii) % k ]) ** 2) 
		#* cc[(k - ii) % k] 
print r

Measured memory_bytes: 85132
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
typedef long long ll;
vector<int> g[200001];
ll score[200001];

void dfs(int v,int pa, ll sum){
    score[v]+=sum;
    for(int i=0;i<g[v].size();i++){
        if(g[v][i]!=pa){
            dfs(g[v][i],v,score[v]);
        }
    }
}
int main(){
    int n,q,a,b,p;
    ll x;
    scanf("%d%d",&n,&q);
    for(int i=0;i<n-1;i++){
        scanf("%d %d",&a,&b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        scanf("%d %lld",&p,&x);
        score[p]+=x;
    }
    dfs(1,-1,0LL);
    for(int i=1;i<=n;i++){
        printf("%lld ",score[i]);
    }
    printf("\n");
}

Measured memory_bytes: 24320
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<i64>();
    println!("{:?}", (n - 2) * 180);
    /*
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut maru = 0;
    for i in 0..s.len() {
        if s[i] == 'o' {
            maru += 1;
        }
    }
    if max(0, 15 - s.len() as i32) + maru >= 8 {
        println!("YES");
    } else {
        println!("NO");
    }
*/
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void)
{
	int in_a, in_b, in_c;
	int out;

	scanf("%d %d %d", &in_a, &in_b, &in_c);
	if ((in_a == in_b && in_a != in_c) || (in_a == in_c && in_a != in_b) || (in_b == in_c && in_b != in_a))
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  S.PB('#');

  int cnt = 1;
  vector<int> v;
  REP(i, N) {
    if (S[i] != S[i + 1]) {
      v.PB(cnt);
      cnt = 1;
    } else {
      cnt++;
    }
  }

  vector<int> rui(v);
  REP(i, rui.size() - 1) rui[i + 1] += rui[i];
  auto psum = [&](int l, int r) {
    int ret = 0;
    ret = rui[min(r, (int)v.size() - 1)];
    if (l > 0) ret -= rui[l-1];
    return ret;
  };
  int p = (S[0] == '1');
  int ans = 0;
  REP(i, v.size()) {
    int sum = 0;
    if ((i + p) % 2 == 0) sum = psum(i+1-2*K, i+1);
    else ans = max(ans, v[i]);
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1272
d,g=map(int,input().split())
l = [list(map(int,input().split())) for i in range(d)]
def f(t,s):
    if t==-1:
        return float('inf')
    num = min(l[t][0],s//((t+1)*100))
    k = num*(t+1)*100
    if num==l[t][0]:
        k += l[t][1]
    if k<s:
        num += f(t-1,s-k)
    return min(num,f(t-1,s))
 
print(f(d-1,g))

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#define INF (1145141919)
using namespace std;

int w[] = {200, 300, 500};
int v[] = {380, 550, 850};
int u[] = {5, 4, 3};
int p[] = {20, 15, 12};
 
int main()
{
	int dp[5001];
	
	for (int i = 1; i <= 5000; i++){
		dp[i] = INF;
	}
	dp[0] = 0;
	
	for (int k = 0; k < 3; k++){
		for (int i = 5000; i >= 0; i--){
			if (dp[i] < INF){
				for (int j = 0; i + j * w[k] <= 5000; j++){
					int yen = dp[i] + v[k] * j;
					yen -= (v[k] * u[k] * p[k] / 100) * (j / u[k]);
					
					dp[i + w[k] * j] = min(dp[i + w[k] * j], yen);
				}
			}
		}
	}
	
	int g;
	while (scanf("%d", &g), g){
		printf("%d\n", dp[g]);
	}
	
	return 0;
}

Measured memory_bytes: 1044
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	x :: Integer <- readLn
	print $ ( x `div` 11 ) * 2 + if
		| x `mod` 11 == 0 -> 0
		| x `mod` 11 <= 6 -> 1
		| otherwise -> 2

Measured memory_bytes: 508
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a;
  cin>>a;
  if(a%2==0||a%5==0){
  out(-1);
  }
  else if(a==7){
  out(1);
  }
  else if(a==1){
  out(1);
  }
  else{
  int b=7%a;
    int c=7%a;
    int d;
    rep(i,1e9+10){
      b=(b+c*10)%a;
      c=(c*10)%a;
      //cout<<b<<' '<<c<<endl;
      if(b==0){
      d=i+2;
        break;
      }
    }
    out(d);
  }
}


Measured memory_bytes: 3764
from itertools import combinations

N, M, X = [ int(i) for i in input().strip().split(' ') ]

C = []
A = []
A_sum = [0] * M
for i in range(N):
    data = [ int(i) for i in input().strip().split(' ') ]
    C.append(data[0])
    A.append(data[1:])
    for j in range(M):
        A_sum[j] += data[j+1]

if min(A_sum) < X:
    print('-1')
else:
    min_C = float('inf')
    for n_select in range(1, N+1):
        for cmb in combinations(range(N), n_select):
            A_sum = [0] * M
            C_sum = 0
            for i in cmb:
                for j in range(M):
                    A_sum[j] += A[i][j]
                C_sum += C[i]
            if (C_sum < min_C) and (min(A_sum) >= X):
                min_C = C_sum
    print(min_C)

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

int main()
{
  string s, t;
  int ans = 0;

  cin >> s >> t;

  for(int i=0; i < s.size(); i++)
  { 
    if(s[i] != t[i]) {
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
const string st[8]={"","SAT","FRI","THU","WED","TUE","MON","SUN"};
int main(){
string st1;
int n;
cin>>n;
cin>>st1;
for (int i=0;i<st1.size();i++) st1[i]=char((st1[i]-'A'+n)%26+'A');
cout<<st1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int DP[101][10001],N,W,v[101],w[101];
int max(int x,int y)
{
  return x > y ? x : y;
}
int dp(int n,int weight)
{
  if(DP[n][weight] != -1)
    return DP[n][weight];
  else if ( weight - w[n] >= 0)
    return DP[n][weight] = max(dp(n-1,weight),dp(n-1,weight-w[n])+v[n]);
  else
    return DP[n][weight] = dp(n-1,weight);

}
int main()
{
  int i,j;
  scanf("%d %d",&N,&W);
  for(i=1;i<=N;i++)
    scanf("%d %d",&v[i],&w[i]);
  for(i=0;i<=W;i++)
    DP[0][i] = 0;
  for(i=1;i<=N;i++)
    for(j=0;j<=W;j++)
      DP[i][j] = -1;
  printf("%d\n",dp(N,W));
  return 0;
}



Measured memory_bytes: 5740
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <functional>
using namespace std;

const int match_number[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int dp[(int)1e4 + 10];
int a[10];

int main() {
	memset(dp, -1, sizeof(dp));
	int n, m;
	scanf("%d%d", &n, &m);
	dp[0] = 0;
	for (int i = 1; i <= m; i++) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + m, greater<int>());
	for (int i = 1; i <= m; i++) {
		for (int j = match_number[a[i]]; j <= n; j++) {
			if (dp[j-match_number[a[i]]] != -1) {
				dp[j] = max(dp[j], dp[j-match_number[a[i]]] + 1);
			}
		}
	}
	while (n) {
		for (int i = 1; i <= m; i++) {
			if (n - match_number[a[i]] >= 0 && dp[n] - dp[n - match_number[a[i]]] == 1) {
				n -= match_number[a[i]];
				printf("%d", a[i]);
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int x,y,i,a,b,x1,y1;

  scanf("%d%d",&x,&y);

  if(x>y){
    a=y;
    y=x;
    x=a;
  }
  for(;;){
    if(x==0)break;
    a=y%x;
    y=x;
    x=a;
  }
  printf("%d\n",y);
  return 0;
}
  



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

using namespace std;

int n;

int main() {
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) { cin >> p[i]; }

	int ans = 0;
	for (int i = 0; i < n - 2; i++) {
		if (p[i + 1] != min(p[i], min(p[i + 1], p[i + 2])) && p[i + 1] != max(p[i], max(p[i + 1], p[i + 2]))) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k,a,b,n;
  cin >> k >> a >> b;
  n=a/k*k;
  if( n==a || n+k <= b){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3608
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 998244353;

void main() {
    auto S = readln.chomp;
    auto N = S.length.to!int;

    long ans = 1;

    auto dp = new long[][](2, 2*N+1); // これまで何個赤を使っているか？
    dp[0][0] = 1;

    int red = 0;
    int blue = 0;
    int cur = 0;
    int tar = 1;

    foreach (i; 0..2*N) {
        dp[tar][] = 0;

        int cand = (i + 1) * 2 - i;

        if (i < N) {
            red += 2 - (S[i] - '0');
            blue += S[i] - '0';
        }

        foreach (used_red; 0..2*N+1) {
            if (dp[cur][used_red] == 0) continue;

            int used_blue = i - used_red;
            int rest_red = red - used_red;
            int rest_blue = blue - used_blue;

            if (rest_red > 0) {
                (dp[tar][used_red+1] += dp[cur][used_red]) %= MOD;
            }
            if (rest_blue > 0) {
                (dp[tar][used_red] += dp[cur][used_red]) %= MOD;
            }
        }
        swap(cur, tar);
    }

    dp[cur][red].writeln;
}


Measured memory_bytes: 380
N = int(input())

dic = {}
for i in range(N):
    s = sorted(input())
    ss = "".join(s)
    if ss in dic:
        dic[ss] += 1
    else:
        dic[ss] = 1

res = 0
for d in dic.values():
    res += d * (d - 1) // 2

print(res)


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

int main(){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3,y3,x4,y4;
    x3=x2+y1-y2;
    y3=y2+x2-x1;
    x4=x3-(x2-x1);
    y4=y3-(y2-y1);

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

}

Measured memory_bytes: 256
# coding: utf-8
import itertools

A, B, C, D = map(int, list(input()))

def minus(x, y):
    return x-y

def plus(x, y):
    return x + y

def eval(opt, x, y):
    if opt == "-":
        return x - y
    else:
        return x + y


for opt1, opt2, opt3 in itertools.product(["-", "+"], repeat=3):
    if eval(opt3, eval(opt2, eval(opt1, A, B), C), D) == 7:
        print("{}{}{}{}{}{}{}=7".format(str(A), opt1, str(B), opt2, str(C), opt3, str(D)))
        exit(0)


Measured memory_bytes: 9112
<?php
 // 入力を受け取る
 $input = trim(fgets(STDIN));
 $l = explode(" ", fgets(STDIN));
 $count = 0;
 for($i = 0; $i < count($l); $i++){
    for($j = $i; $j < count($l); $j++){
        for($k = $j; $k < count($l); $k++){
            $a = (int)$l[$i];
            $b = (int)$l[$j];
            $c = (int)$l[$k];
            if($a == $b || $b == $c || $c == $a){
                continue;
            }
            if( (($a + $b) <= $c) || (($a + $c) <= $b) || (($b + $c) <= $a) ){
                continue;
            }
            $count++;
        }
    }
 }
 echo $count;
?>

Measured memory_bytes: 16144
//header{{{
//#define _GLIBCXX_DEBUG
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost::multiprecision;  
//using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    while(b <= a){
        b *= 2;
        --k;
    }

    while(c <= b){
        c *= 2;
        --k;
    }

    if(k >= 0){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }

    return 0;
}


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

using namespace std;

typedef long long ll;

int n;
ll mat[17][17];
ll cost[(1<<16)+1];
ll D[(1<<16)+1], E[(1<<16)+1], lo[(1<<16)+1];

void calcc(int bit) {
    int i, j;
    for (i=0;i<n;i++) {
        if (~bit>>i&1) continue;
        for (j=0;j<n;j++) {
            if (~bit>>j&1) continue;
            cost[bit]+=mat[i][j];
        }
    }
}

int main() {
    int i, j;

    scanf("%d",&n);
    for (i=0;i<n;i++) for (j=0;j<n;j++) scanf("%lld",&mat[i][j]);
    for (i=0;i<n;i++) lo[1<<i] = i;
    for (i=0;i<(1<<n);i++) calcc(i);
    for (i=0;i<(1<<n);i++) {
        int bit = i;
        vector<int> vec;
        for (;bit;bit&=bit-1) vec.push_back(bit&-bit);
        for (j=1;j<(1<<vec.size());j++) {
            E[j] = E[j&(j-1)]+vec[lo[j&-j]];
            D[i] = max(D[i],D[i^E[j]]+cost[E[j]]);
        }
    }
    printf("%lld\n",D[(1<<n)-1]/2);

    return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s; cin >> s;
    if(s == "SSS") cout << 0 << endl;
    else if(s == "RSS") cout << 1 << endl; 
    else if(s == "SRS") cout << 1 << ednl;
    else if(s == "SSR") cout << 1 << endl;
    else if(s == "RRS") cout << 2 << endl;
    else if(s == "RSR") cout << 1 << endl;
    else if(s == "SRR") cout << 2 << ednl;
    else cout << 3 << endl;
    return 0;
}

Measured memory_bytes: 3652
# -*- coding: utf-8 -*-
# map(int, input().split())
N,X,M = map(int, input().split())

first_A = [X]
mod_M = [False for i in range(M+1)]
mod_M[0] = True
mod_M[1] = True

is_break = False
for i in range(min(N-1,M+1)):
    A_n1 = pow(first_A[-1],2)%M
    if mod_M[A_n1]:
        is_break = True
        last_num = A_n1
        break
    else:
        first_A.append(A_n1)
        mod_M[A_n1] = True

if is_break:
    if last_num == 0:
        print(sum(first_A))
    elif last_num == 1:
        nokori = N-len(first_A)
        print(sum(first_A)+nokori)
    else: # roop
        loop_idx = first_A.index(last_num)
        first_A, second_A = first_A[:loop_idx], first_A[loop_idx:]
        roop = int((N-len(first_A))/len(second_A))
        nokori_kaisuu = (N-len(first_A)) - (roop*len(second_A))
        if nokori_kaisuu == 0:
            print(sum(first_A)+(sum(second_A)*roop))
        else:
            print(sum(first_A)+(sum(second_A)*roop)+sum(second_A[:nokori_kaisuu]))
else:
    print(sum(first_A))

Measured memory_bytes: 76816
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] data=new int[10];
            for (int i = 0; i < 10; i++)
            {
                data[i] = int.Parse(Console.ReadLine());
            }

            Array.Sort(data);
            for (int i = 9; i > 6; i--)
            {
                Console.WriteLine(data[i]);
            }
        }
    }
}

Measured memory_bytes: 5684
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i=0; i<N; i++){
        cin >> a[i];
    }
    int max_a = *max_element(begin(a), end(a));
    int p=0;
    for (int i=0; i<N; i++){
        if (min(p, max_a-p) < min(a[i], max_a-a[i])) p = a[i];
    }
    cout << max_a << " " << p << endl;
    return 0;
}

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

using namespace std;

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

    int A, B;
    cin >> A >> B;

    int cur;
    vector<int> arr;
    for (int i = 0; i < N; i++) {
        cin >> cur;
        arr.push_back(cur);
    }

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

    vector<int> a;
    vector<int> b;
    vector<int> c;

    for (auto one: arr) {
        if (one <= A) {
            a.push_back(one);
        } else if (one >= A + 1 && one <= B) {
            b.push_back(one);
        } else if (one >= B + 1) {
            c.push_back(one);
        }
    }

    int ans = min({a.size(), b.size(), c.size()});
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0) {
            cout << " " << i;
        } else {
            int x = i;
            while(x) {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
}

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

int main(){
	ll a, b, c;
	cin >> a >> b >> c;
	if (a+b > c) {
		cout << "No" << endl;
		return 0;
	}
	ll p = c - a - b;
	p = p*p;
	ll q = 4*a*b;
	if (p > q) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3604
n = int(input())
As = input().split()
As = [int(A) for A in As]
ss = [0]
sss = 0
nd = {0: 1}
for i in range(n):
        sss += As[i]
        ss.append(sss)
        if sss in nd:
            nd[sss] += 1
        else:
            nd[sss] = 1
ans = 0
for k in nd:
    if nd[k] > 0:
        ans += (nd[k] * (nd[k] - 1) // 2)
#for i in range(0, n):
#    for j in range(i + 1, n + 1):
#        if ss[j] - ss[i] == 0:
#            ans += 1
print(ans)

Measured memory_bytes: 38620
#include<iostream>
#include<string>

int main()
{
std::string s; std::cin >> s;
std::string so[3] = {"Sunny", "Cloudy", "Rainy"};
if(s == "Rainy")
{
std::cout << so[0];
}
else if(s == "Sunny")
{
std::cout << so[1];
}
else
{
std::cout << so[2];
}
}

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

int main(){

    int n;
    scanf("%d", &n);

    int counter = 0;
    for(int i=0; i<n; i++){
        int x;
        scanf("%d", &x);
        int tmp = sqrt(x);
        for(int j=1; j<= tmp; j++){
            if(j==1) continue;
            if(x%j==0) {
                counter++;
                break;
            }
        }
    }

    printf("%d\n", n-counter);
    return 0;
}


Measured memory_bytes: 2760
function main()
  
  N = parse(Int,readline())
  x = zeros(N)
  y = zeros(N)
  
  for i in 1:N
    (x[i],y[i]) = map(x -> parse(Int,x), split(readline()))
  end
  
  route_sum = 0
  
  for i in 1:N, j in 1:N
      
    route_sum += sqrt((x[i]-x[j])^2+(y[i]-y[j])^2)
      
  end
  
  println(route_sum / N)
  
end

main()

Measured memory_bytes: 113032
class Node():
    def __init__(self, parent = -1, left = -1, right = -1, depth = 0, height = -1, degree = 0):
        self.parent = parent
        self.left = left
        self.right = right
        self.depth = depth
        self.height = height
        self.degree = degree

def input_depth(node, i, n):
    node[i].depth = n
    if node[i].left != -1:
        input_depth(node, node[i].left, n + 1)
    if node[i].right != -1:
        input_depth(node, node[i].right, n + 1)

def input_height(node, i):
    hl = 0
    hr = 0
    if node[i].left != -1:
        input_height(node, node[i].left)
        hl = node[node[i].left].height + 1
    if node[i].right != -1:
        input_height(node, node[i].right)
        hr = node[node[i].right].height + 1
    node[i].height = max(hl, hr)

def print_node(node, i):
    print("node " + str(i) + ": ", end = "")
    print("parent = " + str(node[i].parent) + ", ", end = "")
    if node[i].parent == -1:
        print("sibling = -1, ", end = "")
    elif i == node[node[i].parent].left:
        print("sibling = " + str(node[node[i].parent].right) + ", ", end = "")
    else:
        print("sibling = " + str(node[node[i].parent].left) + ", ", end = "")
    print("degree = " + str(node[i].degree) + ", ", end = "")
    print("depth = " + str(node[i].depth) + ", ", end = "")
    print("height = " + str(node[i].height) + ", ", end = "")
    if node[i].parent == -1:
        print("root")
    elif node[i].degree == 0:
        print("leaf")
    else:
        print("internal node")
        
n = int(input())
ns = [Node() for i in range(n)]
for i in range(n):
    p, l, r = map(int, input().split())
    if l != -1:
        ns[p].left = l
        ns[p].degree += 1
        ns[l].parent = p
    if r != -1:
        ns[p].right = r
        ns[p].degree += 1
        ns[r].parent = p

for i in range(n):
    if ns[i].parent == -1:
        input_depth(ns, i, 0)
        input_height(ns, i)
        break

for i in range(n):
    print_node(ns, i)





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

int main() {
	int a,b;cin>>a>>b;
	int cnt =0;
	for(int i=a;i<=b;++i){
		int v[5];
		int t = i;
		int d =0;
		while(t>0){
			v[d] = t%10;
			t /=10;
			++d;
		}
		if(v[0]==v[4]&&v[1]==v[3]) ++cnt;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
def examC():
    N = I()
    A1 = LI(); A2 = LI()
    ans = 0
    for i in range(N+1):
        cur = sum(A1[:(i+1)]) + sum(A2[i:])
        ans = max(ans,cur)
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


Measured memory_bytes: 38512
#include<stdio.h>
int main(void)
{
	int n,w,x,z;
	scanf("%d",&n);
	w=0; x=0; z=0;
	w=n/100;
	x=(n%100)/10;
	z=n%10;
	if(w==7||x==7||z==7){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1600
n,m=map(int,input().split())
s=[list(map(int,input().split())) for i in range(n)]
sign=[-1,1]
ans=0
for i in sign:
    for j in sign:
        for k in sign:
            lis=[0]*n
            for l in range(n):
                lis[l]=i*s[l][0]+j*s[l][1]+k*s[l][2]
            lis.sort(reverse=True)
            a=sum(lis[:m])
            ans=max(ans,a)
print(ans)

Measured memory_bytes: 3316
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double a = Double.parseDouble(sc.next());
    double b = Double.parseDouble(sc.next());
    int i = (int) a;
    int j = (int) b;
    int d = i / j;
    int r = i % j;
    double f = a / b;
    String s = String.format("%.5f", f);
    System.out.println(d + " " + r + " " + s);
  }
}



Measured memory_bytes: 26508
import std.stdio;
import std.string;
import std.conv;
import std.array;
import std.typecons;
import std.algorithm;



void main() {
    // 先月の取引を取り込む
    auto prevTradeList = inputTradeList();

    // 今月の取引を取り込む
    auto tradeList = inputTradeList();

    foreach (trade; tradeList.keys.sort()) {
        if (trade in prevTradeList) {
            writeln(join([trade.to!string, (prevTradeList[trade] + tradeList[trade]).to!string], " "));
        }
    }
}

/*
 * 標準入力から取引のデータを取り込み、リストに登録する。
 * 入力の長さが0の場合、終了と見なす。
 */
int[int] inputTradeList() {
    int[int] tradeList;

    foreach (input; stdin.byLine) {
        if (input.length == 0) break;

        auto trade = input.split(",").map!(to!int);
        tradeList = addTradeList(trade[0], tradeList);
    }

    return tradeList;
}

/*
 * 取引履歴を走査し、同じ取引が
 * 1. あれば、その取引のcountをインクリメント
 * 2. なければ、取引履歴に追加
 */
int[int] addTradeList(int tradeId, int[int] prevTradeList) {
    if (tradeId in prevTradeList) {
        prevTradeList[tradeId]++;
    } else {
        prevTradeList[tradeId] = 1;
    }

    return prevTradeList;
}

Measured memory_bytes: 1108
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll int b[200005];
ll int a[200005];
bool compare(const pair<ll int,int>p1,const pair<ll int,int>p2){
if(b[p1.second]==b[p2.second]){return p1.first<p2.first;}
return b[p1.second]<b[p2.second];}
int main()
{
    ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=1;
//cin>>t;
while(t--){
int n,k;
cin>>n>>k;
if(k>((n-1)*(n-2))/2){cout<<-1<<endl;}
else{
cout<<(n*n-n)/2-k<<endl;
int req=(n*n-n)/2-k;
for(int i=1;i<=n-1;i++){
    cout<<n<<" "<<i<<endl;
}
req-=n-1;

       bool b=true;
       int r=1;
    while(b&&r<=n-2){
        for(int i=1;i<=n-1-r;i++){
                if(req==0){b=false;}
                else{
            cout<<i<<" "<<i+r<<endl;
            req-=1;}

            }
            r++;}

        }

    }
}


Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

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

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


int n;
vector<int> a, b, c;
int abc[half_inf + 100][3];

void solve() {
    ll dp[half_inf + 100][3];
    rep(i, half_inf + 100) rep(j, 3) dp[i][j] = 0;
    rep(i, n) {
        rep(j, 3) {
            rep(k, 3) {
                if (j == k) continue;
                chmax(dp[i + 1][j], dp[i][k] + abc[i][j]);
            }
        }
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]});
}

int main() {
    cin >> n;
    a.resize(n), b.resize(n), c.resize(n);
    rep(i, n) {
        cin >> a[i] >> b[i] >> c[i];
        abc[i][0] = a[i];
        abc[i][1] = b[i];
        abc[i][2] = c[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 4992