akhauriyash/Code-Regression huggingface dataset:
package main
 
import (
  "fmt"
  "sort"
)

func main() {
  var n,k int
  fmt.Scan(&n,&k)
  
  v := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&v[i])
  }
  
  ans := 0
  for i := 0; i <= k; i++ {
    for j := 0; j <= k-i; j++ {
      
      if i+j > n {
        continue
      }
      hand := []int{}

      //左からi個追加
      for x := 0; x < i; x++ {
      hand = append(hand,v[x])
      }
      
      //右からj個追加
      for y := n-1; y >= n-j; y-- {
      hand = append(hand,v[y])
      }
      //余っている試行回数(k-i-j)の分だけ捨てるかどうかを判定
      sort.Ints(hand)
      
      for l := 0; l < k-i-j; l++ {
		if len(hand) == 0 {
          break
        }
        if hand[0] < 0 {
		  hand = hand[1:]
		} else {
          break
        }
      }

      sum := 0
      for i := 0; i < len(hand); i++ {
        sum += hand[i]
      }
      if sum > ans {
          ans = sum
      }
    }
  }
  fmt.Println(ans)
}
 

Measured memory_bytes: 1664
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
ati = [[a[0][i],a[1][i],a[2][i]] for i in range(3)]
an1 = [a[0][0],a[1][1],a[2][2]]
an2 = [a[0][2],a[1][1],a[2][0]]
for i in a:
  if all(j in b for j in i):
    print('Yes')
    exit()
for i in ati:
  if all(j in b for j in i):
    print('Yes')
    exit()
if all(j in b for j in an1):
  print('Yes')
  exit()
if all(j in b for j in an2):
  print('Yes')
  exit()
print('No')

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

int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if(a == 0)cout << 1 << endl;
    if(b == 0)cout << 2 << endl;
    if(c == 0)cout << 3 << endl;
    if(d == 0)cout << 4 << endl;
    if(e == 0)cout << 5 << endl;
}

Measured memory_bytes: 3632
module  Main where

import Data.Functor

getInts :: IO [Int]
getInts = map read . words <$> getLine

main :: IO ()
main = do
  {[w,h,x,y,r] <- getInts
  ; putStrLn (check' (w,h,x,y,r))
  }

check :: (Int,Int,Int,Int,Int) -> String
check (w,h,x,y,r)
  | x < r = "NO"
  | y < r = "NO"
  | x > w-r = "NO"
  | y > h-r = "NO"
  | otherwise = "Yes"

check' :: (Int,Int,Int,Int,Int) -> String
check' (w,h,x,y,r)
  | r <= x && x <= w - r && r <= y && y <= h - r = "Yes"
  | otherwise                                    = "No"

Measured memory_bytes: 3668
/*
    In the name of Allah

    MohammadErfan Gooneh

*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define endl                        '\n'
#define all(a, n)                   for (int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define IOS                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
int main() {
    IOS ;
    char b ;
    cin >> b;
    string a = "ATCG";
    //string b = "";
    if(a.find(b)%2)cout << a[a.find(b)-1] ;
    else cout << a[a.find(b)+1] ;



























return 0 ;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef pair <int,int> pii;
typedef vector <pii> vpii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef long long int lli;
typedef vector <lli> vlli;
typedef vector <vlli> vvlli;
typedef vector <string> vs;
typedef vector <bool> vb;

#define rep(i, n) for( i = 0; i < (n); ++i)
#define repA(i, a, n) for( i = a; i <= (n); ++i)
#define repD(i, a, n) for( i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sortr(x) sort(x.begin(),x.end(),greater <int> ())
#define mod 1000000007
#define ff first
#define ss second
#define fill(a,c)  memset(a, c, sizeof (a))
#define formap(i,v) for(auto &i: v)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it<<endl;} cerr<<endl
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it.first<<" , "<<it.second<<endl;} cerr<<endl
#define PI  3.14159265358979323846
#define pb push_back

int N=100001;



int main() {
	cin.sync_with_stdio(0);cin.tie(0);
    cin.exceptions(cin.failbit);
    
    lli i,j,k,n,q,x,s=0,y;
    vi a(N,0);
    cin>>n;
    rep(i,n){
        cin>>x;
        a[x]++;
        s+=x;
    }
    cin>>q;
    rep(i,q){
        // for (int p=1;p<=4;p++)cout<<a[p]<<" ";
        // cout<<endl;
        cin>>x>>y;
        j=a[x];
        a[x]=0;
        a[y]+=j;
        s+= (y-x)*j;
        cout<<s<<endl;
    }
    
    
    
    
    
    
   
   
    
    
   
   
   
   
   
   
	return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N; cin >> N;
  vecll AS(N);
  REP(i, N) cin >> AS[i];
  sort(AS.begin(), AS.end());
  unordered_set<ll> st;

  ll res = 0;
  REP(i, N) {
    if ((i < N) && AS[i+1] == AS[i]) {
      st.insert(AS[i]);
      continue;
    }
    auto ok = true;
    RNG(k, 1, (int)(sqrt((double)AS[i])+1)) if (AS[i]%k == 0 && ((st.find(k) != st.end()) || st.find(AS[i]/k) != st.end())) {
      ok = false;
      break;
    }

    res += ok;
    st.insert(AS[i]);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 13028
k,s=map(int,input().split())
cnt=0
for x in range(k+1):
  if s-x<0:
    break
  elif s-x<=k:
    cnt+=(s-x)+1
  elif s-x>2*k:
    cnt+=0
  elif s-x>k:
    cnt+=2*k-(s-x)+1
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <complex>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

typedef complex<double> Point, Vector;
typedef pair<Point, Point> Segment, Line;
typedef vector<Point> Polygon;

#define X real()
#define Y imag()
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

namespace std{
    bool operator<(const Point &a, const Point &b){
        return !equals(a.X, b.X) ? a.X < b.X : a.Y < b.Y;
    }
}

double cross(Vector a, Vector b){
    return a.X * b.Y - a.Y * b.X;
}

double norm(Vector a){
    return a.X * a.X + a.Y * a.Y;
}

double abs(Vector a){
    return sqrt(norm(a));
}

double convexDiameter(Polygon pol){
    int n = pol.size();
    if(n <= 1) return 0;
    if(n == 2) return abs(pol[0] - pol[1]);

    int i = 0, j = 0;
    for(int k=0; k<n; k++){
        if(!(pol[i] < pol[k])) i = k;
        if(pol[j] < pol[k]) j = k;
    }

    double diameter = 0;
    int si = i, sj = j;
    while(i != sj || j != si){
        diameter = max(diameter, abs(pol[i] - pol[j]));
        if(cross(pol[(i+1)%n] - pol[i], pol[(j+1)%n] - pol[j]) < -EPS){
            i = (i + 1) % n;
        }
        else{
            j = (j + 1) % n;
        }
    }

    return diameter;
}

int main(){
    int n; cin>>n;
    Polygon pol;
    for(int i=0; i<n; i++){
        double x, y; cin>>x>>y;
        pol.emplace_back(x, y);
    }

    printf("%.10f\n", convexDiameter(pol));
}


Measured memory_bytes: 5348
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> S;
    if(S[0] == S[S.size() - 1]) {
    	if(S.size() % 2 == 0) {
    		cout << "First\n";
    	}
    	else {
    		cout << "Second\n";
    	}
    }
    else {
    	if(S.size() % 2 == 1) {
    		cout << "First\n";
    	}
    	else {
    		cout << "Second\n";
    	}
    }
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3680
import java.util.*; 
 
public class Main{
  
  public static void main (String [] args){
    Scanner sc = new Scanner(System.in);     
    int N = sc.nextInt();
    int max = 0;
    int ans = 1;
		
    for(int i = 1; i <= N; i++) {
      int count = 0;
      int temp = i;
			
      while(true) {
        if(temp%2 == 0) {
          temp = temp/2;
          count++;
        }else {
          break;
        }
      }
      if(count > max) {
        max = count;
        ans = i;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35664
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	map<char, int> m;
	rep(i, 0, s.size()) {
		if(m[s[i]] == 0) m[s[i]]++;
		else {
			cout << "no" << endl;
			return 0;
		}
	}
	
	cout << "yes" << endl;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, k);
    string st;
    cin >> st;
    
    vp mmnmm;
    int mm = 0;
    char state = 0;
    rep(i, st.size()) {
        if (state == 0) {
            state = st[i];
            mm++;
        } else if (state != st[i]) {
            mmnmm.pb({mm, (int)(state == '1')});
            mm = 1;
            state = st[i];
        } else {
            mm++;
        }
    }
    mmnmm.pb({mm, (int)(state == '1')});

    int ans = 0, cnt = 0, ret = 0, yui = 0;
    rep(i, mmnmm.size()) {
        if (cnt < k) {
            ans += mmnmm[i].fir;
            if (!mmnmm[i].sec) cnt++;
        } else if (cnt == k) {
            ans += mmnmm[i].fir;
            if (!mmnmm[i].sec) {
                cnt++;
                while (cnt != k) {
                    ans -= mmnmm[yui].fir;
                    cnt -= !mmnmm[yui].sec;
                    yui++;
                }
            }
        }
        //cout << cnt << " " << ans << endl;
        ret = max(ret, ans);
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 2548
(defparameter *n* (read))
(defparameter *t* (read))
(defparameter *c-t* (loop repeat *n*
                          collect (cons (read) (read))))

(defun f (c-t tt)
  (let ((alst (mapcar #'car 
                      (remove-if-not (lambda (pair) (>= tt (cdr pair)))
                                     c-t))))
    (if alst
        (reduce #'min alst)
        "TLE")))

(princ (f *c-t* *t*))

Measured memory_bytes: 13796
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

tmp = float("inf")
ans = 0

for i in range(N):
  num = abs(A - (T - H[i] * 0.006))
  if tmp > num:
    ans = i + 1
    tmp = num

print(ans)

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

int x, a, b, n;
vector<string> s;

int main() {
  cin >> x >> a >> b >> n;
  s.resize(n);
  for(int i = 0; i < n; ++i) {
    cin >> s[i];
    if(s[i] == "nobiro")
      x += a;
    else if(s[i] == "tidime")
      x += b;
    else
      x = 0;
    x = max(x, 0);
  }

  cout << x << endl;
  return 0;
}


Measured memory_bytes: 3240
#include "bits/stdc++.h"
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
#define gcd(a,b) __gcd(a,b)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vc vector<char>
#define pb(n) push_back(n)
#define pp pop_back()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define type(a) typeid(a).name();
#define print(arr) cout << "[" ;for(unsigned int i=0;i<(unsigned int) arr.size();i++){ (i==arr.size()-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define Arr(arr,l) cout << "[" ;for(unsigned int i=0;i<(unsigned int) l;i++){ (i==l-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define console(arr) cout << "["<<endl; for(ll i=0;i<(ll)arr.size();++i){cout << " [";for(ll j=0;j<(ll)arr[i].size();++j){(j==(int)arr[i].size()-1)?cout << arr[i][j]:cout << arr[i][j] << ",";}cout << "]"<<endl;} cout << "]"<<endl
#define starting() auto start = high_resolution_clock::now()
#define ending() auto stop = high_resolution_clock::now();auto duration = duration_cast<microseconds>(stop - start);cout << endl << endl << "Execution Time : "<<duration.count()/1000 << " ms" << endl
 
template <typename T1,typename T2>
void mapped(map<T1,T2>m){for(auto ite=m.begin();ite!=m.end();++ite){cout << "'" << ite->first << "'"<<" : "<<ite->second <<endl;}}
 
template <typename T1 , typename T2>
void mappedArr(map<T1,vector<T2>>m){for(auto ity=m.begin();ity!=m.end();++ity){cout << "'"<< ity->first <<"'"<<" : "<<"[";
for(int i=0;i<(int)ity->second.size();++i){(i==(int)ity->second.size()-1)?cout << ity->second[i]:cout << ity->second[i] << ",";}cout << "]"<<endl;}}
 
string int_to_string(int x){ stringstream ss; ss << x; string ni = ss.str(); return ni;}
int char_to_int(char c){ int n = (int)c - 48; return n; }
int string_to_int(string x){ int n; stringstream s(x); s >> n; return n; }
 
template <typename T1,typename T2>
void ArrPair(vector<pair<T1,T2>>vp){for(int i=0;i<(int)vp.size();++i){
cout << "(" << vp[i].first << "," << vp[i].second << ")"<<endl ;}}
 
const int MOD = 1e9 + 7;
const ll INF = 1e18L + 5;
 
unordered_map<int,int> um;
unordered_set<int> us;
set<int> s;
// v.front() gives the first element of vector 
// v.back()  gives the last element of vector
// insert erase substr

 
int main(){
  ll n1,n2,k;
  cin >> n1 >> n2 >> k;
  if(k>n1){
	  k -= n1;
	  n1 = 0;
  }else {
	  n1 -= k;
	  k = 0;
  }
  if(k>n2){
	  n2 = 0;
	  k  = 0;
  }else {
	  n2 -= k;
	  k = 0;
  }
  cout << n1 << " " << n2; 
  return 0;
}  
 















Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n;
    cin >> n;
    vector<int> a(n);
    vector<P> table(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        table[i] = P(a[i], i);
    }
    sort(table.rbegin(), table.rend());

    constexpr ll inf = 1e+17;
    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, -inf));
    dp[0][0] = 0;
    for(int i = 0; i < n; ++i){
        int cur = table[i].second;
        for(int l = 0; l <= i; ++l){
            int r = i - l;
            chmax(dp[i + 1][l + 1], dp[i][l] + (ll)a[cur] * (cur - l));
            chmax(dp[i + 1][l], dp[i][l] + (ll)a[cur] * ((n - r - 1) - cur));
        }
    }

    ll ans = 0;
    for(int i = 0; i <= n; ++i) chmax(ans, dp[n][i]);
    cout << ans << endl;
}

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

int main()
{
	int n, m, c;
	cin >> n >> m >> c;
	auto b = vector<int>(m);
	for(auto& d : b) cin >> d;
	int ans = 0;
	for(auto i = 0; i < n; ++i){
		int res = c;
		for(auto j = 0; j < m; ++j){
			int a;
			cin >> a;
			res += (a * b[j]);
		}
		if(res > 0) ++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  bool dig[10];
  for (int i = 0; i < 10; ++i) dig[i] = false;
  for (int i = 0; i < k; ++i) {
    int d;
    cin >> d;
    dig[d] = true;
  }
  while (true) {
    for (int i = 0; i < 10; ++i) {
      for (int j = 1; j <= n; j*=10) {
        if (dig[n%(j*10)/j]) goto next_step;
      }
    }
    cout << n << endl;
    return 0;
    next_step:
    n++;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 1002
#define MOD 1000000007
#define ll unsigned long long
using namespace std;

int n, m;
char mapa[MAX][MAX];
ll dp[MAX][MAX];

int main(){

    cin.tie(0);
    ios_base::sync_with_stdio(0);

    cin>>n>>m;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            cin>>mapa[i][j];
        
    dp[1][1] = 1; 
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            if(mapa[i][j] != '#'){
                if(mapa[i][j - 1] != '#')
                    dp[i][j] += dp[i][j - 1] % MOD;
                if(mapa[i - 1][j] != '#')
                    dp[i][j] += dp[i  - 1][j] % MOD;
            }
    cout<<dp[n][m] % MOD;
}

Measured memory_bytes: 12364
N = int(input())
xy = [list(map(float,input().split()))for i in range(N)]
sum = 0
for i in range(N-1):
    for j in range(i+1,N):
        a = (xy[i][0]-xy[j][0])**2
        b = (xy[i][1]-xy[j][1])**2
        sum+= (a+b)**0.5
print(sum*2/N)

Measured memory_bytes: 3188
#include<stdio.h>
int main()
{
    char a[3];
    scanf("%s",a);
    int k=700;
    if(a[0]=='o')
        k=k+100;
     if(a[1]=='o')
        k=k+100;
         if(a[2]=='o')
        k=k+100;
        printf("%d",k);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
using G=vector<vector<int>>;

int main(){
    int a;
    string s;
    cin >> a >> s;
    if(a>=3200) cout << s << endl;
    else cout << "red" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
void cheak(long long int a,long long int b){
  if(b - a % 2 > 0){
    printf("Negative\n");
  }else{
    printf("Positive\n");
  }
}
int main(){
  long long a,b;
  scanf("%lld %lld",&a,&b);
  if(a <= 0 && 0 <= b){
    printf("Zero\n");
  }else if(a < 0){
    cheak(-a + 1,-b);
  }else{
    printf("Positive\n");
  }
  return 0;
}

Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

int n,m;
int ar[305][305];

bool S[305];
int main(){
#ifdef LOCAL_REDIR
  freopen("/home/hog/Dropbox/pg/working/in.txt","r",stdin);
#endif
  cin>>n>>m;
  REP(i,n) REP(j,m) scanf("%d",&ar[i][j]),--ar[i][j];

  REP(i,m) S[i]=true;

  int cnt=m;
  int res=n;
  while(cnt>0){
    int map[305];
    int num[305]={0};
    REP(i,n){
      REP(j,m) if(S[ar[i][j]]){
          map[i]=ar[i][j];
          ++num[ar[i][j]];
          break;
        }
    }
    int mx=0;
    REP(j,m) chmax(mx,num[j]);
    chmin(res,mx);

    REP(j,m) if(S[j] && num[j]==mx){
        S[j]=false;
        --cnt;
      }
  }
  cout<<res<<endl;

  return 0;
}






Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            long a,b,gcd;
            String line = br.readLine();
            StringTokenizer st;
            while(line!=null){
                st=new StringTokenizer(line);
                a=Long.parseLong(st.nextToken());
                b=Long.parseLong(st.nextToken());
                Test t = new Test();
                gcd=t.gcd(a,b);
                System.out.println(gcd + " " + t.lcm(a,b,gcd));
                line = br.readLine();
                }
        } catch (Exception e) {
            System.out.println(e);
        }
    }
}

class Test{
    long r;
    long gcd(long a, long b){
        while(true){
            if(a>b){
                a=a-b;
            }else{
                break;
            }
        }
        if(b%a==0){
            r=a;
        }else{
            gcd(b,a);
        }
        return r;
    }

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

Measured memory_bytes: 24212
#include <stdio.h>

int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W ,&H ,&x ,&y ,&r);
	if( (x-r)>=0 && (y-r)>=0 && (r+x) <= W && (r+y) <= H ){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);

static const int NMAX = 1005;
static const int HMAX = 10005;
static const int INF = 1000000000;


ll dp[NMAX][HMAX];

int main(){
  int h, n;
  cin >> h >> n;
  vector<pair<int,int>> magic(n);
  REP(i,n){
    int a, b;
    cin >> a >> b;
    magic[i].first  = a;
    magic[i].second = b;
  }

//  REP(i,n) cout << magic[i].first << " " <<  magic[i].second << endl;

 //dp初期化


 REP(i,h+1) dp[0][i] = INF;
 REP(i,h+1){
   if(i%magic[0].first == 0){
     dp[1][i] = (i/magic[0].first) * magic[0].second;
    }
    else dp[1][i] = (i/magic[0].first + 1) * magic[0].second;
  }
  for(int i = 1; i < n+1 ; ++i) dp[i][0] = 0;

  //dp table
  ll x, c;

  for(int i = 2; i <= n ; ++i){
    for(int j = 1; j <= h; ++j){
      x = 0, c = 0;
      x = max(0, j - magic[i-1].first);
      c = magic[i-1].second;
      dp[i][j] = min(dp[i-1][j], dp[i][x] + c);
    }
  }

  cout << dp[n][h] << endl;
  return 0;
}


Measured memory_bytes: 81796
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var a = new ArrayList<Integer>();
		for (var i = 0; i < n; i++) {
			a.add(sc.nextInt());
		}
		sc.close();
		Collections.sort(a);
		Collections.reverse(a);

		var count = 0L;
		for (var i = 1; i < a.size(); i++) {
			count += a.get(i / 2);
		}
		System.out.println(count);
	}
}


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

int main(){

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

	int a, b, k ;
	cin >> a >> b >> b >> b >> b >> k ;
	if(k < b-a){

        cout << ":(" ;

	}else{

        cout << "Yay!" ;

	}

}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int m = scan.nextInt();
		int n = scan.nextInt();
		int l = scan.nextInt();
		int[][] data = new int[m][n];
		int[][] datac = new int[n][l];
		long sum = 0;
		for(int i = 0 ; i < m ; i++){
			for(int j = 0 ; j < n ; j++){
				data[i][j]=scan.nextInt();
			}
		}
		for(int i = 0 ; i < n; i ++){
			for(int j = 0 ; j < l ; j++){
				datac[i][j]=scan.nextInt();
			}
		}
		for(int i = 0 ; i < m ; i++){
			for(int k = 0 ; k < l ; k++){
				for(int j = 0 ; j  <n; j++){
					sum+=data[i][j]*datac[j][k];
				}
				System.out.print(sum);
				if(k+1<l) System.out.print(" ");
				sum=0;
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 44932
#include <iostream>

using namespace std;

int main(){

  int N, f = 0, s = 0;

  for(int i = 0; i < 3; i++){
    cin >> N;
    if(N == 5) f++;
    else s++;
  }

  if(f == 2 && s == 1) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;

}


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

int main(){
  int x1,x2,y1,y2;
  
  cin >> x1 >> y1 >> x2 >> y2;
  
  int x = x2 - x1;
  int y = y2 - y1;
  
  int x3 = x2 - y;
  int y3 = y2 + x;
  int x4 = x1 - y;
  int y4 = y1 + x;
  
  cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
  return 0;
}

Measured memory_bytes: 256
s=input()

#i桁以下の数字でmodがjの数
#dp[i][j]=

dp=[[0 for _ in range(13)] for _ in range(len(s))]

MOD=10**9+7

if s[0]!="?":
    dp[0][int(s[0])]=1
else:
    for i in range(10):
        dp[0][i]=1


for i in range(1,len(s)):
    si=s[i]


    if s[i]!="?":
        #数字,300のmodをtempに
        for j in range(13):
            dp[i][(j*10+int(si))%13]+=dp[i-1][j]%MOD
    else:
        for l in range(10):
            for j in range(13):
                dp[i][(j*10+l)%13]+=dp[i-1][j]%MOD
    #print(dp[i],sum(dp[i]))



print(dp[len(s)-1][5]%MOD)




        



Measured memory_bytes: 66012
#include <cstdio>
#include <cmath>

#include <algorithm>
#include <vector>
#include <utility>

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

template<typename T> void swap(T & x, T & y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

const int N =  200000;
const int S = 2000001;

int n, a[N], m, x[N];
int total, val[S], ans[S];


int id[S];
std::vector<int> vec[S];
void uf_init() {
	inc(i, total * 2) {
		id[i] = i;
		vec[i].push_back(i);
	}
}
int unite(int x, int y) {
	int vx = id[x], vy = id[y];
	if(vx == vy) { return vx; }
	
	if(vec[vx].size() < vec[vy].size()) { swap(vx, vy); }
	for(auto && e : vec[vy]) {
		id[e] = vx;
		vec[vx].push_back(e);
	}
	vec[vy].clear();
	
	return vx;
}

int main() {
	scanf("%d", &n);
	inc(i, n - 1) { scanf("%d", &a[i]); }
	scanf("%d", &m);
	inc(i, m) { scanf("%d", &x[i]); }
	
	incID(i, 2, n - 1) { total += a[i]; }
	
	uf_init();
	int sum = 0;
	decID(i, 2, n - 1) {
		sum += a[i];
		inc1(j, a[i]) {
			val[ unite(sum + j, sum - j) ] = sum + j;
		}
	}
	
	incII(i, 0, sum * 2) {
		for(auto && e : vec[i]) {
			ans[e] = val[i];
		}
	}
	
	inc(i, m) {
		printf("%d\n", (x[i] < sum ? ans[ x[i] ] : x[i]) - sum - a[1] + a[0]);
	}
	
	return 0;
}


Measured memory_bytes: 148560
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int x;
  cin >> x;
  cout << (x^1) << endl;
  return 0;
}

Measured memory_bytes: 3528
# include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;
typedef long long ll;


int max(int a, int b) {
  return (a >= b ? a : b);
}


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


ll fact(ll a) {
  if (a != 1) return a * fact(a-1);
  return 1;
}


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

  int ans = n * (n+1) / 2;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (void) {

    int a, b, c;
    int res=0;

    scanf ("%d %d %d", &a, &b, &c);

    for (int i=a; i<=b; i++) {
        if (c%i==0) res++;
    }

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

    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
#define int LL
const int Mod=1e9+7;
int ans=1;
int cnt;
int n,m;
int dp[100005][32];
int solve(int k,int v)
{
	/*if(v<0)return 0;
	if(k>n)return 0;
	if(k==n && v==0)return 1;
	cout<<k<<" "<<v<<endl;
	if(dp[k][v])return dp[k][v];
	int res=0;
	For(i,0,v)res+=dfs(k+1,v-i);
	dp[k][v]=res;
	return res;*/
	memset(dp,0,sizeof(dp));
	dp[0][v]=1;
	rep(i,0,n)
	{
		For(j,0,v)
		{
			For(vv,0,j)
			{
				dp[i+1][j-vv]+=dp[i][j];
				dp[i+1][j-vv]%=Mod;
			}
		}
	}
	return dp[n][0];
}
signed main()
{
	cin>>n>>m;
	int temp=m;
	vec F;
	For(i,2,sqrt(m))
	{
		if(temp%i==0)F.pb(0);
		while(temp%i==0)
		{
			temp/=i;
			F.back()++;
		}
	}
	if(temp>1)F.pb(1);
	rep(i,0,F.size())
	{
		ans*=solve(0,F[i]);
		ans%=Mod;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 25216
n=input()

s=input()
s=s.lower()

list=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
length=len(s)
export=""
for i in range(length):
    num=list.index(s[i])
    num=(num+int(n))%26
    export+=list[num]
    
export=export.upper()
print(export)



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

const int mod = 1e9 + 7;
char grid[1005][1005];

void addmod(int& a, int b){
    a+=b;
    if(a >= mod)
    a-=mod;
}

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<int>> dp(h, vector<int> (w));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> grid[i][j];
        }
    }
    dp[0][0] = 1;
    for(int row = 0; row <h; row++){
        for(int col = 0; col <w; col++){
            for(int r2: {row, row + 1}){
                int c2 = col;
                if(r2==row)
                    c2 = col + 1;
                if(r2 < h && c2 < w && grid[r2][c2]=='.')
                  addmod(dp[r2][c2], dp[row][col]);
            }
        }
    }
    cout << dp[h-1][w-1];
}


Measured memory_bytes: 8496
from collections import deque
s = deque(input())
Q = int(input())
a = True
for i in range(Q):
    t = list(input().split())
    if t[0] == "1":
        a = not(a)
    if t[0] == "2":
        if ((t[1] == "1") and not a ) or ((t[1]=="2") and a ):
            s.append(t[2])
        else:
            s.appendleft(t[2])
if not a :
    s.reverse()
print(*s,sep = "")


Measured memory_bytes: 81200
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int K;
  cin >> K;
  string S;
  cin >> S;
  if (S.length() > K) S = S.substr(0, K) + "...";
  cout << S << endl;
}


Measured memory_bytes: 3656
N = int(input())
count = 0
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
for i in range(N-1):
  count = count + B[A[i]-1]
  if A[i+1] == A[i] + 1:
    count = count + C[A[i]-1]
                      
count = count + B[A[N-1]-1]
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    double t, x;
    cin >> t >> x;
    cout << t / x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }

vector<long long> memo;

int main() {
  long long a,b,c;
  scanf("%lld%lld%lld", &a,&b,&c);
  
  long long sum = a+b+c;

  bool flug = true;
  bool roop = false;
  int count;
  int ans;
  if(a%2==0 && b%2==0 && c%2==0){
    while(flug == true){
      ++count;
      memo.PB(a);
      a = (sum-a)/2;
      b = (sum-b)/2;
      c = (sum-c)/2;
      if(a%2!=0 || b%2!=0 || c%2!=0) flug = false;
      FOR(i,0,memo.size()-1){
        if(memo[i]==a){
          roop = true;
          flug = false;
        }
      }
    }
    ans = count;
  }

  if(roop == true) cout << -1 << endl;
  else if(flug == false) cout << ans << endl;
  else cout << 0 << endl;

}



Measured memory_bytes: 256
#include <cstdio>
#include <vector>
using namespace std;

int main()
{
    int N,v;
    vector<int> A;
    scanf("%d",&N);
    for(int i=0; i<N; i++){
        int a;
        scanf("%d",&a);
        A.push_back(a);
    }
    for(int j=0; j<N-1; j++){
        printf("%d ",A[j]);
    }
	printf("%d\n",A[N-1]);
    int j;
    for(int i=1; i<N; i++){
        v = A[i];
        j = i - 1;
        while(j>=0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        for(int j=0; j<N-1; j++){
            printf("%d ",A[j]);
        }
	    printf("%d\n",A[N-1]);
    }
}

Measured memory_bytes: 2732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main() {
  string S ;
  cin >> S ;
  int N = S.size() ; 
  rep(i,N){
  if( S[2*i] == 'L' || S[2*i+1] == 'R' ){
    cout << "No" << endl;
    break;
  }
  if( i == N-1 ) cout << "Yes" << endl;
  }
}

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

using namespace std;

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

int main(){
	int n;
	ll a[100000];

	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	ll sum = 0;
	for(int i=0;i<n;i++){
		sum += a[i];
	}
	ll ans[100000];
	ans[0] = sum;
	for(int i=1;i<n;i+=2){
		ans[0] -= 2*a[i];
	}
	for(int i=1;i<n;i++){
		ans[i] = 2*a[i-1]-ans[i-1];
	}

	for(int i=0;i<n;i++){
		cout << ans[i] << " ";
	}
	cout << endl;


	return 0;
}


Measured memory_bytes: 2816
#[derive(Copy, Clone, Eq, PartialEq)]
struct State {
    cost: usize,
    position: usize,
}

impl Ord for State {
    fn cmp(&self, other: &State) -> std::cmp::Ordering {
        other
            .cost
            .cmp(&self.cost)
            .then_with(|| self.position.cmp(&other.position))
    }
}

impl PartialOrd for State {
    fn partial_cmp(&self, other: &State) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}

#[derive(Debug, Copy, Clone)]
struct Edge {
    node: usize,
    cost: usize,
}

fn main() {
    let (n, m, mut s): (usize, usize, usize) = (read::<usize>(), read::<usize>(), read::<usize>());
    s = min(2450, s);
    let mut adjl: Vec<Vec<Edge>> = vec![vec![]; 2451 * n];
    for _ in 0..m {
        let (u, v): (usize, usize) = (read::<usize>() - 1, read::<usize>() - 1);
        let (a, b): (usize, usize) = (read::<usize>(), read::<usize>());
        // 0円までに
        for i in a..2451 {
            adjl[i + u * 2451].push(Edge {
                node: (i - a) + v * 2451,
                cost: b,
            });
            adjl[i + v * 2451].push(Edge {
                node: (i - a) + u * 2451,
                cost: b,
            });
        }
    }
    for i in 0..n {
        let (c, d): (usize, usize) = (read::<usize>(), read::<usize>());
        for j in c..2451 {
            adjl[j - c + 2451 * i].push(Edge {
                node: j + 2451 * i,
                cost: d,
            });
        }
    }
    let mut dist: Vec<_> = (0..adjl.len()).map(|_| std::usize::MAX).collect();

    let mut heap = std::collections::BinaryHeap::new();

    dist[s] = 0;
    heap.push(State {
        cost: 0,
        position: s,
    });

    while let Some(State { cost, position }) = heap.pop() {
        if cost > dist[position] {
            continue;
        }

        for edge in &adjl[position] {
            let next = State {
                cost: cost + edge.cost,
                position: edge.node,
            };
            if next.cost < dist[next.position] {
                heap.push(next);
                dist[next.position] = next.cost;
            }
        }
    }
    for i in 1..n {
        let mut ans = std::usize::MAX;
        for j in 0..2451 {
            ans = min(dist[j + i * 2451], ans);
        }
        println!("{}", ans);
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


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

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

    cout << min(a * n, b) << endl;


    return 0;
}

Measured memory_bytes: 256
def solve(n,s,k)
  #p k
  t = (n-1) % k == 0 ? n/2 : n-1
  dp = [0]
  i = k
  while i < t && n-i-1 > k
    #print "#{i} #{n-i-1} "
    dp << dp[-1] + s[i] + s[n-1-i]
    i += k
  end
  #print "\n"
  return dp.max
end

N = gets.to_i
s = gets.split.map(&:to_i)
ans = 0
1.upto(N-1) do |k|
  tmp = solve(N,s,k)
  ans = tmp if ans < tmp
end
p ans

Measured memory_bytes: 21636
# -*- coding: utf-8 -*-
from itertools import permutations
from collections import defaultdict

n,m = map(int, input().split())
edge = defaultdict(lambda: set([]))
for _ in range(m):
    a,b = map(int, input().split())
    edge[a].add(b)
    edge[b].add(a)

def check(p):
    for i in range(n-1):
        if p[i+1] not in edge[p[i]]:
            return False
    return True

res = 0
for r in permutations(range(2,n+1), n-1):
    if check([1]+list(r)):
        res += 1
print(res)

Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
	cin>>n;
	vector<int> cnt(n+1);
	rep(i,n){
		int x;cin>>x;
		cnt[x]++;
	}

	vector<int> sum(n+1);
	rep(i,n+1){
		rep(j,cnt[i])sum[j+1]++;
	}
	rep(i,n)sum[i+1]+=sum[i];
	REP(i,1,n+1){
		int ok=0 ,ng=n+1;
		while(ng-ok>1){
			int mid=(ok+ng)/2;
			if(sum[mid]>=(ll)mid*i)ok=mid;
			else ng=mid;
		}
		cout<<ok<<endl;
	}
	return 0;
}

Measured memory_bytes: 3200
import math
con = 0;
n = int(input())
a = [0]*n

m = int(math.sqrt(n) // 1);
for x in range(1,m+1):
    for y in range(1,m+1):
        for z in range(1,m+1):
            s = x**2 + y**2 + z**2 + x*y + y*z + z*x;
            if s <= n:
                a[s-1] += 1;


for v in range(n):
    print(a[v]);

Measured memory_bytes: 9248
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double a,b;
  cin >> a >> b;
  int c = (a+b)/2;
  if ((a+b)/2 - c >= 0.5){
    cout << c + 1 << endl;
  }else{
    cout << c << endl;
  }
}

Measured memory_bytes: 256