akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin

d = dict()


def gcd(a, b):
    if (a, b) in d:
        return d[(a, b)]
    if b == 0:
        return a
    else:
        res = gcd(b, a % b)
        d[(a, b)] = res
        return res
    return


def gcd_3(a, b, c):
    return gcd(gcd(a, b), c)


def main():
    res = 0
    n = int(input())
    for a in range(1, n+1):
        for b in range(1, n+1):
            m = gcd(a, b)
            if m == 1:
                res += 1*n
            else:
                for c in range(1, n+1):
                    res += gcd(m, c)
    print(res)


def input(): return stdin.readline().rstrip()


main()


Measured memory_bytes: 13212
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
ll a[50][50];
vector<ll> d,dp;

void solve(){
    cin >> n;
    d.resize(1<<n,0);
    dp.resize(1<<n,0);
    rep(i,n){
        rep(j,n){
            cin >> a[i][j];
        }
    }

    rep(s,(1 << n)){
        rep(i,n){
            rep(j,i){
                if (s&(1<<i) && s&(1<<j)) d[s]+=a[i][j];
            }
        }
    }
    rep(s,(1 << n)){
        per(t,(1 << n)){
            t&=s;
            dp[s]=max(dp[s],dp[t]+d[s^t]);
        }
    }

    cout << dp[(1<<n)-1] << endl;
}

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

Measured memory_bytes: 1280
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
wls =[]
for i in range(N):
    wls.append(input())
count =0
if len(wls) != len(set(wls)):
    print('No')
else:
    for i in range(N):
        if i == 0:
            continue
        else:
            if wls[i][0] != wls[i-1][-1]:
                count += 1
            
    if count == 0:
        print('Yes')
    else:
        print('No')
        





Measured memory_bytes: 3060
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  auto n = readln.chomp.to!int;
  auto p = new double[][](n, 2);
  foreach (i; 0..n) {
    p[i] = readln.chomp.split.to!(double[]);
  }

  double sum = 0.0;
  auto f = new bool[](n);
  void calc(int cnt, double dist, int prev) {
    if (cnt == n) {
      sum += dist;
      return;     
    }
    foreach (i; 0..n) {
      if (f[i]) continue;
      f[i] = true;
      auto xx = (p[prev][0] - p[i][0]) ^^ 2;
      auto yy = (p[prev][1] - p[i][1]) ^^ 2;
      auto d = sqrt(xx + yy);
      calc(cnt + 1, dist + d, i);
      f[i] = false;
    }
  }

  foreach (i; 0..n) {
    f[i] = true;
    calc(1, 0, i);
    f[i] = false;
  }

  int fact (int a) {
    if (a == 1) {
      return 1;
    }

    return a * fact(a - 1);
  }
  writefln("%.12f", sum / n / fact(n - 1));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<61;
int iinf=1<<30;
double pi=3.14159265358979323846;
double pi2=pi/2.0;
double eps=1e-8;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,0,-1,0};
int dw[4]={0,1,0,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<0)a=-a;
    if(b<0)b=-b;
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll x,k,d;cin>>x>>k>>d;
    x=abs(x);
    ll syou=x/d;
    ll r=x%d;
    if(syou>k){
        cout<<x-k*d<<endl;
    }
    else{
        if((k-syou)%2)cout<<d-r<<endl;
        else cout<<r<<endl;
    }
}



Measured memory_bytes: 3636
#include <stdio.h>

using namespace std;

int main(){
  char str[1002];
  char temp;
  int len = 0;
  for(int i=0; i < 1000; i++){
    scanf("%c", &temp);
    if('a' <= temp && temp <= 'z'){
      str[i] = temp;
      len++;
    }else{
      break;
    }
  }
  int interv = 0;
  scanf("%d", &interv);
  for(int i=0; i < len; i++){
    if(i%interv == 0){
      printf("%c", str[i]);
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll A, B, C;
  cin >> A >> B >> C;
  ll K;
  cin >> K;
  REP(k, K) {
    if (C <= B)
      C *= 2;
    else if (B <= A)
      B *= 2;
  }
  // cout << A << "," << B << "," << C;
  if (C > B && B > A)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<set>
#include<iomanip>
using namespace std;

int main()
{
	int a,b,c,d,e=0;cin>>a>>b>>c>>d;
	for(int i=0;i<=100;i++)
	{
		if(a<=i&&i<=b&&c<=i&&i<=d)e++;
	}
	cout<<max(0,e-1)<<endl;
	return 0;
}

Measured memory_bytes: 256
'use strict'

function Main(input) {
  const arr = input.split(' ');
  const x = parseInt(arr[0], 10);
  const y = parseInt(arr[1], 10);
  let g = [];
  const a = [1, 3, 5, 7, 8, 10, 12];
  const b = [4, 6, 9, 11];
  const c = [2];

  if (a.indexOf(x) >= 0) {
    g = a;
  } else if (b.indexOf(x) >= 0) {
    g = b;
  } else if (c.indexOf(x) >= 0) {
    g = c;
  }


  if (g.indexOf(y) >= 0) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include <iostream>
#include <string>
using namespace std;
int main() {
  int n;
  cin >> n;
  double total = 0;
  for (int i = 0; i < n; i++) {
    double money;
    string type;
    cin >> money >> type;
    if (type == string("JPY"))
      total += money;
    else
      total += 380000 * money;
  }
  cout << total;
}


Measured memory_bytes: 256
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/5/2 20:44:09
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
LL a,b,n;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	scanf("%lld%lld%lld",&a,&b,&n);
	if(n>=b-1) printf("%lld\n",a*(b-1)/b);
	else printf("%lld\n",a*n/b);
	return 0;
}


Measured memory_bytes: 3812
#include <iostream>
#include <algorithm>
#include <string>
 
using namespace std;
 
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	
	int ans=0;
	for(int i=1;i<n;i++){
		int cnt=0;
		
		for(char c='a';c<='z';c++){
			bool left=false,right=false;
			
			for(int j=0;j<i;j++)
				if(s[j]==c)
					left=true;
			
			for(int j=i;j<n;j++)
				if(s[j]==c)
					right=true;
			
			if(left&&right)
				cnt++;
		}
		
		if(ans<cnt)
			ans=cnt;
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 384
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //var line = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
            var q = int.Parse(ReadLine());
            var answers = new List<int>();
            var isPrime = new bool[100001];
            for(var i = 3; i < isPrime.Length; i += 2)
            {
                isPrime[i] = true;
            }
            isPrime[2] = true;
            for(long i = 3; i < isPrime.Length; i += 2)
            {
                if(!isPrime[i])
                {
                    continue;
                }
                for(long j = i * i; j < isPrime.Length; j += i)
                {
                    isPrime[j] = false;
                }
            }

            var sumLike2017 = new int[100001];
            for(var i = 3; i < sumLike2017.Length; i += 2)
            {
                if(isPrime[i] && isPrime[(i + 1) / 2])
                {
                    sumLike2017[i] = 1;
                }
            }
            for(var i = 3; i < sumLike2017.Length; i++)
            {
                sumLike2017[i] += sumLike2017[i - 1];
            }

            for(var i = 0; i < q; i++)
            {
                var line = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
                var l = line[0];
                var r = line[1];

                answers.Add(sumLike2017[r] - sumLike2017[l - 1]);
            }

            answers.ForEach(value => WriteLine(value));
        }
    }
}


Measured memory_bytes: 19000
#include <stdio.h>

int main()
{
  int N;
  int min=101;
  int max=0;
  int ans=1000000;
  scanf("%d",&N);
  int a[N];
  for(int i=0;i<N;i++)
  {
    scanf("%d",&a[i]);
    if (min>a[i])
      min=a[i];
    if(max<a[i])
      max=a[i];
  }
  for (;min<=max;min++)
  {
    int test=0;
    for(int i=0;i<N;i++)
    {
      int tmp=a[i]-min;
      if(tmp<0)
        tmp*=-1;
      test+=tmp*tmp;
    }
    if (ans>test)
      ans=test;
  }
    printf("%d ",ans);
} 

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

int main(void){
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    if (n*a > b){
        printf("%d\n", b);
    }else{
        printf("%d\n", n*a);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k;
  cin>>n>>k;
  vector<int> arr(n+1, 0);
  int ans = n;
  while(k--){
	  int x,y;
	cin>>x;
	while(x--){
		cin>>y;
		if(arr[y]==0) ans--;
		arr[y]++;
	}
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 3600
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

llvec a[200];
ll N, K;

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, K;
  cin >> N >> K;
  set<P> e;
  if(K>(N-1)*(N-2)/2){
    cout << -1;
    return 0;
  }else{
    rep(i, N-1){
      e.insert({i+1, N});
    }
    ll cnt = (N-1)*(N-2)/2 - K;
    rep(i, N-1){
      FOR(j, i+1, N-1){
        if(cnt==0)break;
        e.insert({i+1, j+1});
        cnt--;
      }
      if(cnt==0)break;
    }

    cout << e.size() <<endl;
    for(auto es: e){
      cout << es.first << " " << es.second << endl;
    }
  }
  
}


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

bool a[101];

int main()
{
	int n,m;
	cin>>n>>m;
	
	int temp1,temp2;
	for(int i=1;i<=m;i++)
	{
		cin>>temp1;
		for(int j=1;j<=temp1;j++)
		{
			cin>>temp2;
			a[temp2]=true;
		}
	}
	
	int cnt=0;
	for(int i=1;i<=n;i++)
		if(!a[i])
			cnt++;
	
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;


int main(){

    ll N;
    cin >> N;
    vector<P>v;
    rep(i, N){
        ll a, b;
        cin >> a >> b;
        v.push_back(P(b, a));
    }
    sort(v.begin(), v.end());
    cout << v[0].first + v[0].second << endl;
    
    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <string>
using namespace std;
 
int main () {
	int a,b,c,i;
	string ans = "NO";

	cin >> a >> b >> c;

	for(i=1;i<b;i++){
		if(i*a%b == c){
			ans = "YES";
		}
	}

	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,a,b,c;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a>>b>>c;
		if(a>b){swap(a,b);}
		if(b>c){swap(b,c);}
		if(a>b){swap(a,b);}
		if(a*a+b*b==c*c){
			cout<<"YES"<<endl;
		}
		else {
			cout<<"NO"<<endl;
		}

	}
return 0;
}


Measured memory_bytes: 3104
#include<cstdio>//AT2043
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>

using namespace std;

int vjudge;

int n,m;

char ch[2]={'.','#'};

char ch2[2]={' ','\n'};

int red[502][502],blue[502][502];

char purple[502][502];

int main(){
    scanf("%d%d",&n,&m);
    scanf("\n");
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            scanf("%c",&purple[i][j]);
        }
        if(i<n){
            scanf("\n");
        }
    }
    for(int i=1;i<=n;i++){
        if(i%2){
            for(int j=1;j<m;j++){
                red[i][j]=1;
            }
            blue[i][m]=1;
        }
        else{
            for(int j=2;j<=m;j++){
                blue[i][j]=1;
            }
            red[i][1]=1;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(red[i][j]==0&&purple[i][j]==ch[1]){
                red[i][j]=1;
            }
            if(blue[i][j]==0&&purple[i][j]==ch[1]){
                blue[i][j]=1;
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            printf("%c",red[i][j]?ch[1]:ch[0]);
        }
        printf("\n");
    }
    printf("\n");
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            printf("%c",blue[i][j]?ch[1]:ch[0]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
using namespace std;
typedef long long int ll;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	ll r = a % b;
	while (r) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, t, ans = 1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t;
		ans = ans / gcd(ans, t)*t;
	}
	cout << ans << endl;
	return 0;
}

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

public class P
{
	public int Lx { get; set; }
	public int Ly { get; set; }
	public int rx { get; set; }
	public int ry { get; set; }
}

public class hello
{
	public static char[,] mapL, mapr;
	public static int w, h;
	public static int Lsx, Lsy, rsx, rsy;
	public static int Lgx, Lgy, rgx, rgy;

	public static void Main()
	{
		while (true)
		{
			string[] line = Console.ReadLine().Trim().Split(' ');
			w = int.Parse(line[0]);
			h = int.Parse(line[1]);
			if (w == 0 && h == 0) break;
			mapL = new char[h, w];
			mapr = new char[h, w];
			Lsx = Lsy = rsx = rsy = 0;
			Lgx = Lgy = rgx = rgy = 0;
			for (int i = 0; i < h; i++)
			{
				line = Console.ReadLine().Trim().Split(' ');
				for (int j = 0; j < w; j++)
				{
					mapL[i, j] = line[0][j];
					if (line[0][j] == 'L') { Lsx = i; Lsy = j; mapL[i, j] = '.'; }
					if (line[0][j] == '%') { Lgx = i; Lgy = j; mapL[i, j] = '.'; }
					mapr[i, j] = line[1][j];
					if (line[1][j] == 'R') { rsx = i; rsy = j; mapr[i, j] = '.'; }
					if (line[1][j] == '%') { rgx = i; rgy = j; mapr[i, j] = '.'; }
				}
			}
			var ans = goBfs(Lsx, Lsy, rsx, rsy);
			Console.WriteLine(ans);
		}
	}
	static string goBfs(int Lsx, int Lsy, int rsx, int rsy)
	{
		var used = new bool[h, w, h, w];
		used[Lsx, Lsy, rsx, rsy] = true;
		var dx = new int[] { 0, 1, 0, -1 };
		var dy = new int[] { 1, 0, -1, 0 };
		var q = new Queue<P>();
		q.Enqueue(new P { Lx = Lsx, Ly = Lsy, rx = rsx, ry = rsy });
		while (q.Count() > 0)
		{
			var a = q.Dequeue();
			//Console.WriteLine("Lx = {0} Ly = {1} rx = {2} ry = {3} step = {4}",a.Lx,a.Ly,a.rx,a.ry,a.step);
			if (a.Lx == Lgx && a.Ly == Lgy && a.rx == rgx && a.ry == rgy) return "Yes";
			if ((a.Lx == Lgx && a.Ly == Lgy && !(a.rx == rgx && a.ry == rgy))) continue;
			if (!(a.Lx == Lgx && a.Ly == Lgy) && a.rx == rgx && a.ry == rgy) continue;
			for (int i = 0; i < 4; i++)
			{
				var nLx = a.Lx + dx[i];
				var nLy = a.Ly + dy[i];
				var nrx = a.rx + dx[i];
				var nry = a.ry - dy[i];
				if (!(nLx >= 0 && nLx < h && nLy >= 0 && nLy < w)) { nLx = a.Lx; nLy = a.Ly; }
				if (!(nrx >= 0 && nrx < h && nry >= 0 && nry < w)) { nrx = a.rx; nry = a.ry; }
				if (mapL[nLx, nLy] == '#') { nLx = a.Lx; nLy = a.Ly; }
				if (mapr[nrx, nry] == '#') { nrx = a.rx; nry = a.ry; }
				if (!used[nLx, nLy, nrx, nry])
				{
					q.Enqueue(new P { Lx = nLx, Ly = nLy, rx = nrx, ry = nry});
					used[nLx, nLy, nrx, nry] = true;
				}
			}
		}
		return "No";
	}
}



Measured memory_bytes: 40728
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
int main(){
  string s;
  int o=0,k;
  while(cin>>s){
    for(int i=0;i<s.size();i++) if(s[i]<'0'||s[i]>'9') s[i]=' ';
    stringstream ss(s);
    while(ss>>k) o+=k;
  }
  cout << o << endl;
  return 0;
}

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

signed main(){
	int n,ans=1e17;
	cin>>n;
	int a[n],s[n];
	r(i,n)cin>>a[i];
	int l=-1e10-1,r=1e10+1;
	while(l<r){
		int m=(l+r)/2;
		int s0=0,s1=0,s2=0;
		r(i,n){
			s0+=abs((i+1+m)-a[i]);
			s1+=abs((i+1+m-1)-a[i]);
			s2+=abs((i+1+m+1)-a[i]);
		}
		if(s1<s0&&s0<s2)r=m;
		else l=m+1;
		if(s1>=s0&&s0<=s2){
			cout<<s0<<endl;
			exit(0);
		}
	}
}

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

#define LARGE 100000
int V,E;
int color=0;

typedef struct list{
  int id;
  struct list *next;
}list;


list * makelist(int x){
  list *new = malloc(sizeof(list));
  new->id = x;
  new->next = NULL;
  return new;
}

void list_insert(list* L[], int x, list *new){
	list **p = &L[x];
	
	while((*p) != NULL){
	  p = &((*p)->next);
	}
	(*p) = new;
	
	return;
}

int push(int stack[], int x, int top){
  stack[top++] = x;
  return top;
}

int pop(int stack[], int *top){
  (*top)--;
  return stack[*top];
}

void dfs(int C[], int x, list* L[]){
  int stack[LARGE];
  int top = 0;
  int temp;
  list *p;
	
  color++;
  top = push(stack,x,top);
  while(top > 0){
    temp = pop(stack,&top);
    if(C[temp] == 0) C[temp] = color;
    p = L[temp];
    while(p != NULL){
      if(C[p->id] == 0){
	top = push(stack,p->id, top);
	C[p->id] = color;
			}
      p = p->next;
		}
  }
	
  return;
}

int main(){
  int i, j, s, t, q, x, y, C[LARGE];
  list *L[LARGE], *new;
 
  scanf("%d %d", &V, &E);
	
  for(i = 0 ; i < V ; i++){
    L[i] = NULL;
    C[i] = 0;
  }
	
  for(i = 0 ; i < E ; i++){
    scanf("%d %d", &s, &t);
    new = makelist(t);
    list_insert(L, s, new);
    new = makelist(s);
    list_insert(L, t, new);
  }
	
  scanf("%d", &q);
  for(i = 0 ; i < q ; i++){
    scanf("%d %d", &x, &y);
    if(C[x] == 0) dfs(C, x, L);
    if(C[y] == 0) dfs(C, y, L);
    if(C[x ]== C[y]) printf("yes\n");
    else printf("no\n");
  } 
		
  return 0;
}


Measured memory_bytes: 9144
s = input()
n = len(s)

s = "".join(reversed(list(s)))
while n:
    if s.startswith("maerd"):
        n -= 5
        s = s[5:]
    elif s.startswith("remaerd"):
        n -= 7
        s = s[7:]
    elif s.startswith("esare"):
        n -= 5
        s = s[5:]
    elif s.startswith("resare"):
        n -= 6
        s = s[6:]
    else:
        break
print("YES" if n == 0 else "NO")

Measured memory_bytes: 10388
#include <cstdio>
#include <set>
#include <algorithm>
#include <cassert>

const long long INF=1e18+7;

struct ShiftMultiset{
  std::multiset<long long> set;
  long long delta;
  //x in set represents x+delta
  void insert(long long x){
    set.insert(x-delta);
  }
  void shift(long long x){
    delta+=x;
  }
  long long front(){
    assert(set.size());
    return *set.begin()+delta;
  }
  long long back(){
    assert(set.size());
    return *set.rbegin()+delta;
  }
  long long pop_front(){
    assert(set.size());
    long long x=*set.begin();
    set.erase(set.begin());
    return x+delta;
  }
  long long pop_back(){
    assert(set.size());
    long long x=*set.rbegin();
    set.erase(set.find(*set.rbegin()));
    return x+delta;
  }
}left,right;

int ls[100005];
int rs[100005];

int main(){
  int N;
  scanf("%d",&N);
  for(int i=1;i<=N;i++){
    scanf("%d %d",&ls[i],&rs[i]);
  }
  long long cost=0;//cost at min
  left.insert(0);
  right.insert(INF);
  for(int i=1;i<=N;i++){
    left.shift(-(rs[i]-ls[i]));
    right.shift((rs[i-1]-ls[i-1]));
    if(ls[i]<left.back()){
      cost+=std::abs(left.back()-ls[i]);
      left.insert(ls[i]);
      left.insert(ls[i]);
      right.insert(left.pop_back());
    }else if(ls[i]>right.front()){
      cost+=std::abs(right.front()-ls[i]);
      right.insert(ls[i]);
      right.insert(ls[i]);
      left.insert(right.pop_front());
    }else{
      left.insert(ls[i]);
      right.insert(ls[i]);
    }
  }
  printf("%lld\n",cost);
}


Measured memory_bytes: 10368
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


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

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_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int N, K;
  cin >> N >> K;

  if(N%K == 0) cout << 0 << endl;
  else cout << 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int n, a, b, i, suma, sumb;
   scanf("%d", &n);
   while ( n ) {
       suma = sumb = 0;
       for ( i = 0; i < n; i++ ) {
           scanf("%d %d", &a, &b);
           if ( a > b ) suma += a + b;
           else if ( a < b ) sumb += a + b;
           else {suma +=a; sumb +=b;}
       }
       printf("%d %d\n", suma, sumb);
       scanf("%d", &n);
   }
   return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define pow             ilmh
using namespace std;

typedef unsigned long long ULL;

const int N = 304;
int n;
string str;
char s[N][N];

ULL HashRow[N][N], HashCol[N][N], pow[N];

ULL getRow(int id, int i, int j) { if (i > j) return 0; return HashRow[id][j] - HashRow[id][i-1] * pow[j-i+1]; }
ULL getCol(int id, int i, int j) { if (i > j) return 0; return HashCol[j][id] - HashCol[i-1][id] * pow[j-i+1]; }
void prepareHash() {
    for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j)
        HashRow[i][j] = HashRow[i][j-1] * 31LL + s[i][j] - 'a' + 1;
    for (int j = 1; j <= n; ++j) for (int i = 1; i <= n; ++i)
        HashCol[i][j] = HashCol[i-1][j] * 31LL + s[i][j] - 'a' + 1;
    pow[0] = 1;
    for (int i = 1; i <= n; ++i) pow[i] = pow[i-1] * 31LL;
}

int Real(int pos) {
    int ans = (pos + n) % n;
    return (ans == 0) ? n : ans;
}

bool ok[N];

void sol() {
    prepareHash();

    int res = 0;
    for (int A = 0; A < n; ++A) {
        for (int B = 0; B < n; ++B) ok[B] = true;
        for (int i = 1; i <= n; ++i) for (int B = 0; B < n; ++B) {
            int col = Real(i + A - B);
            int row = Real(1 + B - A);
            if (getRow(i, 1, n - row + 1) != getCol(col, row, n)) ok[B] = false;
            if (getRow(i, n - row + 2, n) != getCol(col, 1, row-1)) ok[B] = false;
        }
        for (int B = 0; B < n; ++B) res += ok[B];
    }
    cout << res;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> str;
        for (int j = 1; j <= n; ++j) s[i][j] = str[j-1];
    }

    sol();

    return 0;
}


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

using namespace std;

int main(){

int number , Main , sum = 0;
int Main2;

cin >> number;
Main = number;

while (Main != 0){
    Main2 = Main % 10;
    sum = sum + Main2;
    Main = Main / 10;
}

if ( number % sum == 0 ){
    cout << "Yes";
}
else{
  cout << "No";
}

return 0;
}


Measured memory_bytes: 256
import sys

n, *p = map(int, sys.stdin.read().split())

def main():
    cnt = 0
    big = p[1] > p[0]
    for i in range(1, n-1):
        if big:
            cnt += 1 & (p[i] < p[i+1])
        else:
            cnt += 1 & (p[i] > p[i+1])
            
        big = p[i+1] > p[i]

    return cnt

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
n,m = map(int,input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
for i in range(n-m+1):
  for j in range(n-m+1):
    for k in range(m):
      if b[k] != a[i+k][j:j+m]:
        break
      if k == m-1:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
using namespace std;
long long A, B, result;

int main()
{
    scanf("%lld %lld", &A, &B);
    if(A % 2 == 1 && B % 2 == 0)
    {
        result = A ^ B ^ ((B - A) / 2 % 2);
    }
    else if(A % 2 == 1)
    {
        result = A ^ ((B - A) / 2 % 2);
    }
    else if(B % 2 == 0)
    {
        result = B ^ ((B - A) / 2 % 2);
    }
    else
    {
        result = (B - A + 1) / 2 % 2;
    }
    printf("%lld", result);
}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

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

main = do
	getLine
	as <- readInts
	print $ maximum as - minimum as

Measured memory_bytes: 1020
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main() {
    int k, i=0;
    long long n;
    scanf("%lld %d", &n, &k);
    while(1) {
        if(pow(k, i) > n) {
            printf("%d\n", i);
            break;
        } else {
            ++i;
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int h[1000009];
int main()
{
    int n,m,x,y;
    cin>>n>>m;

    for (int i=1; i<=n; ++i)
    {
        cin>>h[i];
    }

    map<int,int>mp;
    for (int i=0; i<m; ++i)
    {
        cin>>x>>y;
        if (h[x]<h[y])
        {
            mp[x]=1;
        }
        if (h[x]>h[y])
        {
            mp[y]=1;
        }
        else if (h[x]==h[y])
        {
            mp[x]=1;
            mp[y]=1;
        }
    }
    int ans=0;
    for (int i=1; i<=n; ++i)
    {
        if (mp[i]==0 )
            ++ans;
    }
    cout<<ans;







}


Measured memory_bytes: 8704
import heapq


n = int(input())
M = {}
for _ in range(n):
    u, k, *line = map(int, input().split())
    tmp = []
    for i in range(k):
        v, w = line[2*i:2*i+2]
        tmp.append((v, w))
    M[u] = tmp

INF = 10**10
WHITE = 0
GREY = 1
BLACK = 2
d = [INF for i in range(n)]
d_heap = []
color = [WHITE]*n
p = [-1]*n


def dijkstra():
    d[0] = 0
    p[0] = -1
    heapq.heappush(d_heap, (0, 0))

    while len(d_heap):
        # 最も小さいnodeを持ってくる、これもheapで処理したい。
        _, u = heapq.heappop(d_heap)
        color[u] = BLACK

        # heapで距離更新
        for v, w in M[u]:
            if color[v] != BLACK:
                if d[u]+w < d[v]:
                    d[v] = d[u]+w
                    p[v] = u
                    heapq.heappush(d_heap, (d[v], v))


dijkstra()
for i in range(n):
    print(i, d[i])



Measured memory_bytes: 68976
n,m = map(int, input().split())
room = [[] for i in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    room[a-1].append(b-1)
    room[b-1].append(a-1)
mark = [-1] * n
mark[0] = 0
q = []
q.append(0)

while len(q):
    now = q.pop(0)
    for i in room[now]:
        if mark[i] == -1:
            mark[i] = now
            q.append(i)

print("Yes")
for i in mark[1:]:
    print(i+1)


Measured memory_bytes: 34344
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();
        int N = r.i();
        int[][] V = new int[N][2];
        for(int i = 0; i < N; i++){
            V[i] = r.ii();
        }
        long R2 = 0;
        for(int i = 0; i < 100; i++){
            double theta = 2*Math.PI*i/100;
            double a = Math.cos(theta);
            double b = Math.sin(theta);
            long X = 0;
            long Y = 0;
            for(int[] v : V){
                long x = v[0];
                long y = v[1];
                if(a*x+b*y > 0){
                    X += x;
                    Y += y;
                }
            }
            long r2 = X*X+Y*Y;
            if(r2 > R2){
                R2 = r2;
            }
        }
        println(Math.sqrt(R2));
    }

    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 24660
# https://atcoder.jp/contests/abc079/tasks/abc079_c
n = input()
op_cnt = len(n) - 1  # すき間の個数
for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt  # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  # フラグが立っていた箇所を "+" で上書き

    formula = ""
    for p_n, p_o in zip(n, op + [""]):  # 少々モヤッとする
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break


Measured memory_bytes: 3060
using System;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		long[][] arr=new long[n][];
		long v=0;
		for(int i=0;i<n;i++){
			arr[i]=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
			if(i!=0){
				if(Math.Abs(arr[i][0]+arr[i][1])%2!=v){v=-1;break;}
			}
			else{v=Math.Abs(arr[i][0]+arr[i][1])%2;}
		}
		if(v==-1){Console.WriteLine("{0}",-1);}
		else{
			Console.WriteLine("{0}",31+(v^1));
			long[] u=new long[31+(v^1)];
			for(int i=0;i<31;i++){u[i]=1<<i;}
			if(v==0){u[31]=1;}
			Console.WriteLine(String.Join(" ",u));
			for(int i=0;i<n;i++){
				string s="";
				for(int j=30;j>=0;j--){
					if(Math.Abs(arr[i][0])>Math.Abs(arr[i][1])){
						if(arr[i][0]>0){
							s="R"+s;
							arr[i][0]-=u[j];
						}
						else{
							s="L"+s;
							arr[i][0]+=u[j];
						}
					}
					else{
						if(arr[i][1]>0){
							s="U"+s;
							arr[i][1]-=u[j];
						}
						else{
							s="D"+s;
							arr[i][1]+=u[j];
						}
					}
				}
				if(v==0){
					if(arr[i][0]==1){s+="R";}
					else if(arr[i][0]==-1){s+="L";}
					else if(arr[i][1]==1){s+="U";}
					else{s+="D";}
				}
				Console.WriteLine(s);
			}
		}
	}
}

Measured memory_bytes: 15428
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>
#include <complex>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }




int main() {
	int n; cin >> n;
	
	int v[110];
	int b[110][110]; minit(b, -1);
	int ans = -1000000000;
	
	for_(i, 0, n) {
		for_(j, 0, n) cin >> v[j];
		
		for_(j, 0, n) {
			int s = 0;
			for_(k, j, n) {
				s += v[k];
				b[j][k] = max(b[j][k], 0) + s;
				ans = max(ans, b[j][k]);
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if ((((max(a,b)-min(a,b))<=d)+((max(b,c)-min(b,c))<=d)+2*((max(c,a)-min(c,a))<=d))>=2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
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;
}
signed main() {
    int X;
    cin >> X;
    int s = 100;
    int ans = 0;
    while(s < X) {
        ans++;
        s += s / 100;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3596
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<lint> d(n);
    REP(i, n){
        cin >> d[i];
    }
    sort(ALL(d));
    lint m1 = n / 2 - 1;
    lint m2 = n / 2;
    //debugpair(m1, m2);
    lint ans = d[m2] - d[m1];
    if(d[m2] == d[m1]){
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
from itertools import zip_longest as Zip
s=input()
l=len(s)-1
ans=0
for i in range(2**l):
  d=s
  ans+=eval("".join([x+y for x,y in Zip(d,format(i,"b").zfill(l).replace("0","#").replace("1","+"),fillvalue="")]).replace("#",""))
print(ans)  

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define mod 1000000007LL
#define eps 0.0001

#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------

    int k;
    string s;
    cin >> k >> s ;

    int i;
    int x = 0;
    int ans =0;
    for(char req:s){
        if(req=='I') x++;
        else x--;
        ans = max(ans,x);
    }
    pri(ans);


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}
template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

void imos(vector<int>& a){
    int n = a.size();
    vi s(n+1,0);

    rep(i,n){
        int l = max(0, i - a[i]);
        int r = min(n, i + a[i] + 1);
        s[l]++;
        s[r]--;
    }

    rep(i,n) s[i+1] += s[i];
    a = s;
    a.resize(n);
}

int main(){
    int n,k;cin >> n >> k;
    vi a(n);
    cin >> a;
    vi c(n, n);
    rep(i,k){
        imos(a);
        if(a == c) break;
    }

    cout << a << "\n";
}

Measured memory_bytes: 6424