akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;

class _Class
{
  void _Do()
  {
    var tmp = Split.ints();
    var N = tmp[0];
    var a = new int[N,3];
    for (int i=0;i<N;i++)
    {
      tmp = Split.ints();

      a[i, 0] = tmp[0];
      a[i, 1] = tmp[1];
      a[i, 2] = tmp[2];
    }

    //
    var dp = new int[N,3];

    for (int i = 0; i < N; i++)
    {
      for (int ii=0;ii<3;ii++) {
        // dp = a[i]
        dp[i, ii] =
          a[i, ii];

        // dp += dp[i-1]
        if(i>=1)
          dp[i,ii]+=
          Math.Max(
            dp[i - 1, (ii+1)%3], dp[i - 1, (ii+2)%3]);
      }
    }
    int ret = 0;
    for(int i=0;i<=2 ; i++)
    {
      ret = Math.Max(ret,dp[N - 1,i]);
    }
    Console.WriteLine(ret);
  }

  static void Main(string[] args)
  {
    _(args);
    new _Class()._Do();
  }

  [Conditional("DEBUG")]
  static void _(string[] args)
  {
    if (args.Length != 0 && File.Exists(args[0]))
      Console.SetIn(new StreamReader(args[0]));
    else
      Console.Error.WriteLine("in");
  }
}

static class Split
{ 

  // 1
  public static string[] strings()
  {
    return Console.ReadLine().Split();
  }


  // [2.1] -2,147,483,648 ~ +2,147,483,647
  public static int[] ints()
  {
    var _s = Console.ReadLine().Split();

    var x = new int[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = int.Parse(_s[i]);

    return x;
  }

  // [2.2] 
  // -9,223,372,036,854,775,808 ~ 
  // +9,223,372,036,854,775,807
  public static long[] longs()
  {
    var _s = Console.ReadLine().Split();

    var x = new long[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = long.Parse(_s[i]);

    return x;
  }

  public static double[] doubles()
  {
    var _s = Console.ReadLine().Split();

    var x = new double[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = double.Parse(_s[i]);

    return x;
  }

  public static BigInteger[] bigs()
  {
    var _s = Console.ReadLine().Split();

    var x = new BigInteger[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = BigInteger.Parse(_s[i]);

    return x;
  }
}







Measured memory_bytes: 19392
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29

def main():
    s = input()
    if s[0]==s[1] and s[1]==s[2]:
        print("No")
    else:
        print("Yes")
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38384
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>
# include <thread>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;

#define CHECK_IMPL1(cond)              \
if (!(cond)) {                         \
    DEBUG("expected cond: " << #cond); \
    assert(cond);                      \
}

#define CHECK_IMPL2(cond, message)                                            \
if (!(cond)) {                                                                \
    DEBUG("expected cond: " << #cond << " failed with message: " << message); \
    assert(cond);                                                             \
}
#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << std::endl;
#else
#define DEBUG(message)
#endif

void solve() {
  int n, len;
  cin >> n >> len;

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

  int pos = -1;
  for (int i = 0; i + 1 < n; i++) {
    if (pos == -1 || a[i] + a[i + 1] > a[pos] + a[pos + 1]) {
      pos = i;
    }
  }

  vector<int> res;
  if (pos + 1 < n && a[pos] + a[pos + 1] >= len) {
    res.push_back(pos + 1);
    for (int i = pos + 1; i + 1 < n; i++) {
      res.push_back(i + 1);
    }
    for (int i = pos - 1; i >= 0; i--) {
      res.push_back(i + 1);
    }
  } else if (pos > 0 && a[pos - 1] + a[pos] >= len) {
    res.push_back(pos + 1);
    for (int i = pos - 1; i >= 0; i--) {
      res.push_back(i + 1);
    }
    for (int i = pos + 1; i + 1 < n; i++) {
      res.push_back(i + 1);
    }
  } else {
    cout << "Impossible\n";
    return;
  }
  cout << "Possible\n";
  reverse(res.begin(), res.end());
  for (auto x : res) {
    if (x == n) {
      continue;
    }
    cout << x << "\n";
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef __APPLE__
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 1784
n,m=map(int,input().split())
buf=[0]*m
ans=0
for i in range(n):
    fav=list(map(int,input().split()))
    for j in range(1,fav[0]+1):
        buf[fav[j]-1]+=1
for i in range(m):
    if buf[i]==n:
        ans+=1
print(ans)
    


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

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var a = ReadInts();

            WriteLine(a.Max() - a.Min());
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

    }
}


Measured memory_bytes: 11732
#WA 2018-01-01 15:35:55 => Fix
N=input()
a=[tuple( map(int,raw_input().split()) ) for i in range(N-1)]
#print a
 
for i in range(N-1):
	val=0
	for c,s,f in a[i::]:
		if val<=s:
			val=s+c
		else:
			if val%f==0:
				val+=c
			else:
				val=f*((val/f)+1)
				val+=c

	print val
print 0

Measured memory_bytes: 2692
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstdlib>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

int main(){
    string a, b;
    cin >> a >> b;
    string n = a + b;
    int num = 0;
    for (int i = 0; i < n.size(); i++){
        num *= 10;
        num += n[i] - '0';
    }
    for (int i = 0; i * i <= num; i++){
        if (num == i * i){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

}

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

ll Q, H, S, D;
ll N;

void solve(){
	S = min(4 * Q, min(2 * H, S));
	D = min(2 * S, D);
	printf("%lld\n", N / 2 * D + (N - (N / 2 * 2)) * S);
}

int main(){
	scanf("%lld %lld %lld %lld", &Q, &H, &S, &D);
	scanf("%lld", &N);
	solve();
	return 0;
}


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

int main() {
    string str1, str2, str3;
    int max_in, ans;
    vector <int> num(3);
    
    for (int i = 0; i < 3; i++) cin >> num.at(i);
    
    sort(num.begin(),num.end(),greater<int>());
    
    str1 = to_string(num[0]);
    str2 = to_string(num[1]);
    str3 = str1 + str2;
    max_in = atoi(str3.c_str());
    ans = max_in + num[2];
    
    cout << ans<< endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int gyo,retu;
  int matrix[1001][1001] = {{}};
  int vector[1001] = {};
  
  scanf("%d %d", &gyo, & retu);

  for(int i=0; i < gyo; i++){
    for(int j=0; j < retu; j++){
      scanf("%d",&matrix[i][j]);
    }
  }

  for(int i=0; i < retu; i++){
    scanf("%d",&vector[i]);
  }


  int sumretu;
  for(int i=0; i < gyo; i++){
    sumretu = 0;
    for(int j=0; j < retu; j++){
      sumretu += matrix[i][j] * vector[j];
    }
    printf("%d\n",sumretu);
  }

  return 0;
}



Measured memory_bytes: 6640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(){
  string s;
  int a=0,b=0,c=0;
  cin >>s;
  for(int i=0;s[i]!='\0';i++){
    if(s[i]=='a')a=1;
    if(s[i]=='b')b=1;
    if(s[i]=='c')c=1;
  }
  if(a+b+c==3)cout<<"Yes"<<endl;
  if(a+b+c!=3)cout<<"No"<<endl;
}

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

class Graph
{
	int vertex;
	vector<vector<int>> adj;
	vector<int> dp;
	vector<bool> vis;
public:
	Graph(int vertex);
	void addEdge(int u, int v);
	void dfs(int source);
	int longest_path();
};

Graph :: Graph(int vertex)
{
	this->vertex = vertex;
	adj.resize(vertex);
}

void Graph :: addEdge(int u, int v)
{
	/* Remember to add directed edge */
	adj[u].push_back(v);
}

void Graph :: dfs(int source)
{
	vis[source] = true;

	if(adj[source].empty())
		return;

	int mx = 0;
	for(auto child : adj[source])
	{
		if(not vis[child])
			dfs(child);

		mx = max(mx, dp[child]);
	}

	dp[source] = 1 + mx;
}

int Graph :: longest_path()
{
	dp.assign(vertex, 0);
	vis.assign(vertex, false);

	int mx = 0;
	for(int i = 0; i < vertex; i++)
	{
		if(vis[i])
			continue;

		dfs(i);
		mx = max(mx, dp[i]);
	}

	return mx;
}

void solve()
{
	int vertex, edges;
	cin >> vertex >> edges;

	Graph g(vertex);
	for(int i = 0; i < edges; i++)
	{
		int u, v;
		cin >> u >> v;
		u--; v--;

		g.addEdge(u, v);
	}

	cout << g.longest_path() << endl;
}

int main()
{
	solve();
	return 0;
}


Measured memory_bytes: 12420
// while( !(succeed == try()) );

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

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


#define int long long int
#define loop(i,s,e) for(int i=s; i<e; i++)
#define endl '\n'
#define vii vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX

void INP();

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


void alpha()
{	
	int n;
	cin>>n;

	int t = n;
	while(t){
		int curr = t%10;
		t/=10;
		if(curr == 7){
			cout<<"Yes";
			return;
		}
	}

	cout<<"No";
}

int32_t main(){

	ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//INP();
    int t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}






















inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}
 
 

Measured memory_bytes: 3664
from math import sqrt

if __name__ == '__main__':
    Q = int(input())
    values = [list(map(int, input().split())) for _ in range(Q)]
    As, Bs = zip(*values)

    for A, B in zip(As, Bs):
        A, B = min(A, B), max(A, B)

        # A = B
        if A == B:
            print(2 * A - 2)
            continue

        # A + 1 = B
        if A + 1 == B:
            print((A - 2) + (B - 2) + 1)
            continue

        C = int(sqrt(A * B))
        if C == sqrt(A * B):
            C -= 1

        # C(C + 1) >= AB
        if C * (C + 1) >= A * B:
            print(2 * C - 2)
            continue

        # C^2 < AB
        if C ** 2 < A * B:
            print(2 * C - 1)
            continue


Measured memory_bytes: 3064
import java.math.BigInteger;
import java.util.*;
import java.io.*;
import java.text.*;
public class Main{
    //SOLUTION BEGIN
    //Into the Hardware Mode
    void pre() throws Exception{}
    void solve(int TC)throws Exception {
        long h = nl(), a = nl();
        pn((h+a-1)/a);
    }

    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    void exit(boolean b){if(!b)System.exit(0);}
    long IINF = (long)1e15;
    final int INF = (int)1e9+2, MX = (int)2e6+5;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-7;
    static boolean multipleTC = false, memory = true, fileIO = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        if(fileIO){
            in = new FastReader("");
            out = new PrintWriter("");
        }else {
            in = new FastReader();
            out = new PrintWriter(System.out);
        }
        //Solution Credits: Taranpreet Singh
        int T = (multipleTC)?ni():1;
        pre();
        for(int t = 1; t<= T; t++)solve(t);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    int find(int[] set, int u){return set[u] = (set[u] == u?u:find(set, set[u]));}
    int digit(long s){int ans = 0;while(s>0){s/=10;ans++;}return ans;}
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }

        String nextLine() throws Exception{
            String str = "";
            try{
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }
            return str;
        }
    }
}

Measured memory_bytes: 24660
#include<bits/stdc++.h>
#define N 1025
using namespace std;
int n,m;
string pd[N],sou[N],des[N];
string s1,s2,s3;

struct ans{
  string s1,s2,s3;
  ans(){};
  ans(string a,string b,string c){s1=a,s2=b,s3=c;};
};

int main(){

  while(1){
    
    cin>>n>>m;
    if(!n&&!m)break;

    for(int i=0;i<n;i++)
      cin>>pd[i]>>sou[i]>>des[i];

    vector<ans> A;
    
    for(int i=0;i<m;i++){

      cin>>s1>>s2>>s3;

      for(int j=n-1;j>=0;j--){
	
	int f=0;
	for(int k=0;k<8;k++){
	  if(sou[j][k]=='?')continue;
	  if(sou[j][k]!=s1[k])f=1;
	}
	
	for(int k=0;k<8;k++){
	  if(des[j][k]=='?')continue;
	  if(des[j][k]!=s2[k])f=1;
	}
	
	if(!f&&pd[j]=="deny")break;
	if(!f&&pd[j]=="permit"){
	  A.push_back(ans(s1,s2,s3));
	  break;
	}
	
      }
      
    }

    cout<<A.size()<<endl;

    for(int i=0;i<A.size();i++)
      cout<<A[i].s1<<' '<<A[i].s2<<' '<<A[i].s3<<endl;
    
    
  }
  
  return 0;
}

Measured memory_bytes: 3372
N = int(input())
W = list(map(int, input().split()))
sum_T1 = 0
sum_T2 = 0
ans = []

for i in range(N):
    sum_T1 += W[i]
    sum_T2 = sum(W) - sum_T1
    ans.append(abs(sum_T1 - sum_T2))

print(min(ans))


Measured memory_bytes: 38512
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {

        Integer[] input = readInput();

        Arrays.sort(input, 0, 3);
        System.out.printf("%d %d %d\n", input[0], input[1], input[2]);
    }


    public static Integer[] readInput() {
        List<Integer> l = new ArrayList<Integer>();

        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            l.add(sc.nextInt());
        }
        return l.toArray(new Integer[l.size()]);
    }
}

Measured memory_bytes: 26340
#!/usr/bin/env python3
import itertools

N = int(input().split()[0])
p_list = list(input().split())
q_list = list(input().split())

pp = itertools.permutations(p_list, N)
pp = list(sorted(["".join(x) for x in pp]))

qp = itertools.permutations(q_list, N)
qp = list(sorted(["".join(x) for x in qp]))

p = "".join(p_list)
q = "".join(q_list)

p_index = qp.index(p)
q_index = qp.index(q)

ans = abs(p_index - q_index)
print(ans)


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

int H,W;

bool check(int x, int y){
  bool ret = true;
  if(x < 0 || x >= H) ret = false;
  if(y < 0 || y >= W) ret = false;
  
  return ret;
}

int main(){
  cin >> H >> W;
  vector<vector<int>> dp(H, vector<int>(W,0));
  
  int dx[4] = {0,1,0,-1};
  int dy[4] = {1,0,-1,0};
  vector<string> S(H);
  for(int i = 0; i < H; i++){
    cin >> S.at(i);
  }
  
  bool ans = true;;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      
      if(S.at(i).at(j) == '.') continue;
      
      int nx, ny;
      bool tmpans = false;
      for(int k = 0; k < 4; k++){
        nx = i + dx[k];
        ny = j + dy[k];
        if(check(nx,ny)){
          if(S.at(nx).at(ny) == '#'){
            tmpans = true;
            break;
          }
        }
      }
      if(tmpans){
        continue;
      } else { 
        ans = false;
        break;
      }
    }
    if(ans) continue;
    else break;
  }
  
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string input = ReadLine();
        int kazu = int.Parse(input);
        int wa = 0;
        int temp = kazu;
        
        for(int i=0;i<=10;i++){
            wa += temp%10;
            temp /= 10;
            if(temp == 0){
                break;
            }
        }
        if(kazu % wa ==0){
            WriteLine("Yes");
        }else{
            WriteLine("No");
        }
    }
}

Measured memory_bytes: 13140
n = int(input())
a = list(map(int, input().split()))

target = sum(a)//2

b = a[1:n:2]
a.append(a[0])

ans = []
ans.append((target-sum(b))*2)

for i in range(n-1):
    num = a[i] - ans[i]//2
    ans.append(num*2)

for i in range(n):
    print(ans[i], end=' ')

Measured memory_bytes: 14616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define mod (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}


void solve() {
    int n, m;
    cin >> n >> m;
    cout << (n == m ? "Yes" : "No")  << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  String po=sc.next();
  int length=po.length();
  String p=po.replace("1","");
  po=po.replace("0","");
  System.out.println(Math.min(p.length(),po.length())*2);
}
}


Measured memory_bytes: 33224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;
    if (s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3128
// ??\???????????\??????
var input = require("fs").readFileSync("/dev/stdin","utf8");

var array = (input.trim()).split("\n");
for (var i = 0; i < array.length; i++) {
 var splited = array[i].split(" ");
//??§?????????????????????
 splited.sort(function(d, e){
   return e - d
 })
 test(splited)
}


// ?????\??????????????????????????????
function test(data) {
   var a = data[0]
   var b = data[1]
  // c_multi=????°???¬?????° gcd=?????§??¬?´???°
  // ?????§??¬?´???°????±???????
  var x = a;
  var y = b;
  var z;
  while ((z = x % y) != 0) {
    x = y
    y = z
  }
  var gcd = y
  // ????°???¬?????°????±???????
  var lcm = a * b / gcd
  // ??¨?¨?
  console.log(gcd + " " + lcm)
}

Measured memory_bytes: 15508
n, m = map(int, input().split())
if n == 1 and m == 1:
    print(1)
elif n == 1:
    print(m-2)
elif m == 1:
    print(n-2)
elif n==2 or m==2:
    print(0)
else:
    print((m-2)*(n-2))

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> num(N+1);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
    if(a.at(i)<=N) num.at(a.at(i)-1)++;
    else num.at(N)++;
  }
  int ans=0;
  for(int i=0; i<N; i++){
    if(num.at(i)<i+1) ans+=num.at(i);
    else ans+=num.at(i)-(i+1);
  }
  ans+=num.at(N);
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
 
		ArrayList<Long> array = new ArrayList<>();
 
		for (int i = 0; i < n; i++) {
			array.add(sc.nextLong());
		}
 
		long sum = 0;
		for (int j = 0; j < n - 1; j++) {
			long diff = array.get(j) - array.get(j + 1);
			if (diff > 0) {
				sum += diff;
				array.set(j + 1, array.get(j + 1) + diff);
			}
		}
 
		System.out.println(sum);
 
	}
}

Measured memory_bytes: 69072
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int n;
cin>>n;
si s;
for(int i=0;i<n;i++ )
{
	int x;
	cin>>x;
	s.insert(x);
}
if(size(s)==n)
cout<<"YES";
else
	cout<<"NO";
}
int main()
{
//code
	
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>

using namespace std;

long long n = 0, a = 0, b = 0, sets = 0, ans = 0;

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

	sets = n / (a + b);
	ans = a * sets + min(n - (a + b) * sets, a);

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <stack>
#include <cctype>
#include <string>
#include <iostream>
#include <cstdlib>
using namespace std;

stack<int> a;


int givePop()
{
    int t = a.top();
    a.pop();
    return t;
}


bool strIsdigit(string t)
{
    for(int i = 0;i < t.length();i++)
    {
        if(!isdigit(t[i]))  return false;
    }
    return true;
}

int main()
{
    string in;
    int sum = 0;

    while(cin>>in)
    {
        if(strIsdigit(in))  a.push(atoi(in.c_str()));
        else                 
        {
            int op2 = givePop();
            int op1 = givePop(); 

            if(in == "+")
                sum = op1 + op2;
            else if(in == "-")
                sum = op1 - op2;
            else if(in == "*")
                sum = op1 * op2;
            a.push(sum);
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3232
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
    int n = scan!int;
    long[] as = scan!long(n);

    auto psta = new Stack!S;
    long[] xs = new long[](n); // xs[i] は i の左方に続く as[i] より大きい数の最終位置
    foreach(i, a; as){
        while(! psta.isEmpty && psta.peek.value > a) psta.pop;
        if(psta.isEmpty) xs[i] = 0;
        else xs[i] = psta.peek.pos + 1;
        psta ~= S(i, a);
    }
    log("xs:", xs);

    auto qsta = new Stack!S;
    long[] ys = new long[](n); // ys[i] は i の右方で初めて as[i] より小さい数の位置
    foreach_reverse(i, a; as){
        while(! qsta.isEmpty && qsta.peek.value > a) qsta.pop;
        if(qsta.isEmpty) ys[i] = n;
        else ys[i] = qsta.peek.pos;
        qsta ~= S(i, a);
    }
    log("ys:", ys);

    long ans;
    foreach(i; 0 .. n) ans += as[i] * (i - xs[i] + 1) * (ys[i] - i);

    ans.writeln;
}
struct S{
    long pos, value;
}

// ----- スタック -----
class Stack(T){
	private T[] xs;
	private uint j; // j : 次に書き込む位置
	this(){	}
	this(T[] xs){ this.xs = xs; j = xs.length.to!uint; }
	uint length(){ return j; }
	bool isEmpty(){ return j == 0; }
	void push(T x){
		while(j + 1 >= xs.length) xs.length = xs.length * 2 + 1;
		xs[j ++] = x;
	}
    Stack opOpAssign(string op)(T x){
        if(op == "~"){ push(x); return this; }
        assert(0, "Operator " ~ op ~ "= not implemented");
    }
	T pop(){ assert(j > 0); return xs[-- j]; }
	T peek(){ assert(j > 0); return xs[j - 1]; }
	T opIndex(uint li){ assert(j > 0 && j - 1 >= li); return xs[j - 1 - li]; }
	static Stack!T opCall(){ return new Stack!T; }
	static Stack!T opCall(T[] xs){ return new Stack!T(xs); }
	T[] array(){ return xs[0 .. j]; }
	override string toString(){ return array.to!string; }
}


Measured memory_bytes: 18192
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let n: usize = read_line().trim().parse().unwrap();
    let a: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut ans = 0;
    let mut l = 0;
    let mut r = 0;
    let mut mask = 0;
    while l < n {
        while r < n && mask & a[r] == 0 {
            mask |= a[r];
            r += 1;
        }
        ans += r - l;
        mask -= a[l];
        l += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 10492
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

#define num_cells 3

void ABC081A (void)
{
	// local variables for this function
	char         given_data[num_cells];
	int          retval_scanf;
	unsigned int num_marbles;

	// STEP.01
	// read out the given string
	retval_scanf = scanf("%s", given_data);

	// STEP.02
	// find the number of squares on which Sunuke will place a marble
	num_marbles = (unsigned int)(0);

	for (int iter = 0; iter < num_cells; ++iter)
	{
		if ( given_data[iter] == '1' ) ++num_marbles;
	}

	// STEP.03
	// print the answer of this task to the standard output
	printf( "%d\n", num_marbles );

	// STEP.END
	return;
}

int main (void)
{
	// STEP.01
	// calculate & output the answer
	ABC081A();

	// STEP.END
	return EXIT_SUCCESS;
}

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

int main()
{
	int h, w;
	while (cin >> h >> w) {
		if (h == 0) break;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cout << "#";
			}
			cout << "\n";
		}
		cout << "\n";
	}
}


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

const ll MOD=1000000007;

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear1(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p){
  ll n=solveLinear1(a,p,1);
  n=n%p;
  if(n<0)return n+p;
  return n;
}

ll L[51];
ll a[51];

ll patty(ll x,int n){
  if(x<=0)return 0;
  if(n==0)return 1;
  if(x>=L[n])return a[n];
  ll cnt=patty(x-1,n-1)+patty(x-2-L[n-1],n-1);
  if(x>L[n-1]+1)cnt++;
  return cnt;
}

int main(){
  int i,j,k;ll cnt=0;
  int n;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)cin>>a[i];
  for(i=0;i<n;i++){
    if(a[i]%2==1){
      cout<<"first"<<endl;
      return 0;
    }
  }
  cout<<"second"<<endl;
}


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
ll dp[1<<16] = {};

int main(){
  int N;
  while(cin>>N && N){
    ll ans = 0;
    memset(dp, 0, sizeof(dp));
    REP(i, N){
      int M; ll L;
      cin>>M>>L;
      int mask = 0;
      REP(t, M){
        int S, E;
        cin>>S>>E;
        S -= 6; E -= 6;
        for(int j = S; j < E; j++) mask |= (1 << j);
      }
      for(int S = (1<<16) - 1; S >= 0; S--)if((mask & S) == 0){
        int next = S | mask;
        dp[next] = max(dp[next], dp[S] + L);
        ans = max(ans, dp[next]);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1380
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 100011

int n, i;
int a[maxN];
int dp_inc[maxN], dp_dec[maxN], dp[maxN];

int main()
{
   // freopen("test.in","r",stdin);

    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
        scanf("%d", &a[i]);

        dp_inc[i] = dp_dec[i] = 1;
        if (a[i - 1] <= a[i] && i > 1) dp_inc[i] = 1 + dp_inc[i - 1];
        if (a[i - 1] >= a[i] && i > 1) dp_dec[i] = 1 + dp_dec[i - 1];

        dp[i] = 1 + min(dp[i - dp_inc[i]], dp[i - dp_dec[i]]);
    }

    printf("%d", dp[n]);




    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){

  string s;
  cin >> s;
  int a = 200001, z = 0, ans = 0;

  for (int i = 0; i < s.size(); i++) {
    if(s[i] == 'A') a = min(i,a);
    if(s[i] == 'Z') z = max(i,z);
  }

  cout << z-a+1 << endl;

  return 0;
}

Measured memory_bytes: 640
n = gets.chomp
orders = gets.chomp.split.map(&:to_i)

count = 0
orders.each_cons(3) do |con|
  if con[0] < con[1] && con[1] < con[2]
    count += 1
  elsif con[0] > con[1] && con[1] > con[2]
    count += 1
  end
end

puts count

Measured memory_bytes: 1788
/*100 点の科目がある 	A
数学と英語の平均点が 90 点以上 	A
3 科目の平均点が 80 点以上 	A
3 科目の平均点が 70 点以上 	B
3 科目の平均点が 50 点以上で数学か英語が 80 点以上 	B
上の条件を満たさない 	C*/
#include<iostream>
using namespace std;
int main(){
	for(;;){
		int n;
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			int a,b,c;
			cin>>a;
			cin>>b>>c;
			if(a==100||b==100||c==100){
				cout<<"A"<<endl;
			}	
			else if((a+b)/2>=90){
				cout<<"A"<<endl;
			}
			else if((a+b+c)/3>=80){
				cout<<"A"<<endl;
			}
			else if((a+b+c)/3>=70){
				cout<<"B"<<endl;
			}
			else if((a+b+c)/3>=50&&a>=80){
				cout<<"B"<<endl;
			}	
			else if((a+b+c)/3>=50&&b>=80){
				cout<<"B"<<endl;
			}
			else{
				cout<<"C"<<endl;
			}
		}
	}
}					



Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
using namespace std;

int main() {
	int A, B,C = 0;
	cin >> A >> B;

	if (A%B != 0) {
		C = 1;
	}

	cout << A/B+C -A/B << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n, d;

int main()
{
	scanf("%d%d", &n, &d);
	
	int count = 0;
	int next = 1;
	while (next <= n)
	{
		count++;
		next = next + 2 * d + 1;
	}
	
	printf("%d\n", count);

	return 0;
}
	

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;++i)
#define Sort(a) sort(a.begin(),a.end())
const int INF = 1e9+7;

int main(){
  int H,W,cnt=-1;
  cin >> H >> W;
  vector<vector<char>> s(H,vector<char>(W));
  vector<vector<int>> b(H,vector<int>(W));
  vi dh = {0,1,-1,0}, dw = {1,0,0,-1};
  rep(i,H){
    rep(j,W){
      cin >> s.at(i).at(j);
      b.at(i).at(j) = INF;
      if(s.at(i).at(j)=='.')
        ++cnt;
    }
  }
  queue<P> q;
  b.at(0).at(0) = 0;
  q.push(P(0,0));
  while(q.size()){
    P p = q.front(); q.pop();
    if(p.first==H-1&&p.second==W-1)
      break;
    rep(i,4){
      int nh = p.first + dh.at(i);
      int nw = p.second + dw.at(i);
      if(0<=nh&&nh<H&&0<=nw&&nw<W&&s.at(nh).at(nw)!='#'&&b.at(nh).at(nw)==INF){
        q.push(P(nh,nw));
        b.at(nh).at(nw) = b.at(p.first).at(p.second) + 1;
      }
    }
  }
  if(cnt-b.at(H-1).at(W-1)<0)
    cout << "-1" << endl;
  else
    cout << cnt - b.at(H-1).at(W-1) << endl;
}


Measured memory_bytes: 256
def judge(character):
	if character == "A" or character == "T" or character == "C" or character == "G":
		return 1
	else:
		return 0

a = list(input())
total = [0]
turn = 0
for i in range(len(a)):
	b = judge(a[i])
	if b == 1:
		total[turn] += 1
	else:
		turn += 1
		total.append(0)
print(max(total))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include<map>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<typeinfo>
#include<queue>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<pair<int,int>> work(N);
	for (int i = 0; i < N; i++) {
		cin >> work[i].second>>work[i].first;
	}
	sort(work.begin(), work.end());
	int t=0;
	bool flag = true;
	for (int i = 0; i < N; i++) {
		if (t+work[i].second<=work[i].first) {
			t += work[i].second;
		}
		else {
			flag = false;
			break;
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int main() {
  int n, i;
  long sum = 0;
  cin >> n;
  
  for(i = 1; i <= n; i++)
  {
    if(i%3 == 0 || i%5 == 0)
    {
    }
    else
    {
      sum += i;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 3628
// finish date: 2018/01/20
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int R, G;
    cin >> R >> G;
    cout << R + (G - R) * 2 << endl;
    return 0;
}


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

int main(){

long long  n,k;
cin >> n >>k;
long long h[n];
rep(i,n)cin >> h[i];
sort(h,h+n,greater<long long >());
if(n<k)cout << 0 << endl;
else{
    long long count=0;
    for(int i=k;i<n;i++){
        count +=h[i];
    }
    cout << count << endl;
}

}




Measured memory_bytes: 1792
#include<iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
int N,M,Q,A,B,v,d,c;
long long ans=0;
typedef pair<int,int> S;
typedef pair<int,S> T;
typedef pair<S,S> P;
T color[100005]={};
int main(){
	cin>>N>>M;
	vector<int> road[100005];
	for(int i=0;i<M;++i){
		cin>>A>>B;
		road[A].push_back(B);
		road[B].push_back(A);
	}
	priority_queue<P,vector<P> > que;
	cin>>Q;
	for(int i=1;i<=Q;++i){
		cin>>v>>d>>c;
		que.push(P(S(d,i),S(v,c)));
	}
	while(!que.empty()){
		P p=que.top();que.pop();
		int v1=p.second.first,d1=p.first.first,c1=p.second.second,I1=p.first.second;
//		if((color[v1].second.first>=I1&&color[v1].second.second>=d1)||d1<0)continue;
		if(color[v1].second.first<I1)color[v1]=T(c1,S(I1,d1));
		for(int i=0;i<road[v1].size();++i){
			int v2=road[v1][i];
			if((color[v2].second.first>=I1&&color[v2].second.second>=d1-1)||d1==0)continue;
			if(color[v2].second.first<I1)color[v2]=T(c1,S(I1,d1-1));
			que.push(P(S(d1-1,I1),S(v2,c1)));
		}

	}
	for(int i=1;i<=N;++i){
		cout<<color[i].first<<endl;
	}
	return 0;
}


Measured memory_bytes: 17644
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

const int MAX = 100007;
const int MOD = 1000000007;

void solve() {
    int a[MAX][3], n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    // if (n == 1) {cout << max(a[1][0], max(a[1][1], a[1][2]));}
    int dp[MAX][3];
    dp[1][0] = max(a[1][0], max(a[1][1], a[1][2]));
    dp[1][1] = max(a[1][0], max(a[1][1], a[1][2]));
    dp[1][2] = max(a[1][0], max(a[1][1], a[1][2]));
    for (int i = 2; i <= n; i++) {
        dp[i][0] = max(dp[i - 1][1] + a[i][0], dp[i - 1][2] + a[i][0]);
        dp[i][1] = max(dp[i - 1][2] + a[i][1], dp[i - 1][0] + a[i][1]);
        dp[i][2] = max(dp[i - 1][0] + a[i][2], dp[i - 1][1] + a[i][2]);
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("in.in", "r", stdin); freopen("out.out", "w", stdout);
    //int tt; cin >> tt; for (int i = 1; i <= tt; i++) {cout << "Case #" << i << ": "; solve();}
    solve();
}

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

using namespace std;

#define int long long

int n;
int a[200010];
int an;
map<int, int> q;

main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    q[0] = 1;
    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += a[i];
        an += q[sum];
        q[sum]++;
    }
    cout << an << endl;
}


Measured memory_bytes: 14336
#include "bits/stdc++.h"
using namespace std;
int dp[1000000], inf = 200000, mi = 1000000000;
int main()
{
    for (int i = 0; i < 1000000; ++i)
    {
        dp[i] = 100000000;
    }
    dp[0] = 0;
    int d, g;
    scanf("%d%d", &d, &g);
    g /= 100;
    for (int i = 1, p, c; i <= d; ++i)
    {
        scanf("%d%d", &p, &c);
        c /= 100;
        for (int j = inf; j >= 0; --j)
        {
            for (int k = 1; k <= p; ++k)
            {
                if (k == p)
                {
                    dp[j + i * k + c] = min(dp[j + i * k + c], dp[j] + k);
                }
                else
                {
                    dp[j + i * k] = min(dp[j + i * k], dp[j] + k);
                }
            }
        }
    }
    for (int i = g; i < inf; ++i)
    {
        mi = min(mi, dp[i]);
    }
    printf("%d\n", mi);
}


Measured memory_bytes: 4096
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    if N == 0 and A[0] > 1:
        print(-1)
        return 0
    low, high = A[N], A[N]
    maxN = [0] * (N + 1)
    maxN[N] = A[N]
    Limit = [2 ** 50] * (N + 1)
    Limit[N] = A[N]

    for i in reversed(range(N)):
        leaf = A[i]
        Limit[i] = min(Limit[i], Limit[i+1] + leaf)
        if i <= 50: Limit[i] = min(pow(2, i), Limit[i])
        low = (low + 1) // 2 + leaf
        high += leaf
        if low > Limit[i]:
            print(-1)
            break
        else: 
            maxN[i] = min(high, Limit[i])
    else:
        for i in range(N):
            if (maxN[i] - A[i]) * 2 <= maxN[i+1]: maxN[i + 1] = (maxN[i] - A[i]) * 2
        print(sum(maxN))

    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 26908
#include <bits/stdc++.h>
using namespace std;
#define rp(i,k,n) for(int i=(k); i<(n); i++)
int main() {
  int n, x;
  cin >> n >> x;
  int m[110];
  int minn = 1000;
  rp(i,0,n){
    cin >> m[i];
    x -= m[i];
    minn = min(minn, m[i]);
  }
  x /= minn;
  cout << x + n << endl;
}

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

int qmin(int a, int b){
	return (a < b) ? a : b;
}

int h, n;
int A[1010], B[1010];
int dp[20020];

int main(){
	cin >> h >> n;
	rep(i, n) cin >> A[i] >> B[i];
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	rep(i, n){
		rep(j, h+1){
			dp[j+A[i]] = qmin(dp[j+A[i]], dp[j] + B[i]);
		}
	}
	int ans = 0x3f3f3f3f;
	for(int i = h; i <= 20010; i++) ans = qmin(ans, dp[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define inf 2000000000
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define rng_23 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef set<int> si;
typedef multiset<int> msi;
typedef map<int,int> mii;
int ara[200001],pos[200001];
int main()
{
    int i,j,k;
    int n;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>ara[i];
        pos[ara[i]]=i;
    }
    int mx=0;
    i=1,j=2;
    while(i<=n){
        while(pos[j]>pos[j-1] && j<=n)
            j++;
        mx=max(mx,j-i);
        i=j;
        j++;
        //cout<<i<<endl;
    }
    cout<<n-mx;
}


Measured memory_bytes: 1920
N, M = gets.split.map{|i|i.to_i}
a = []
N.times{a << gets.chomp}
b = []
M.times{b << gets.chomp}
f = false
(0 .. (N - M)).each{|y|
    (0 .. (N - M)).each{|x|
        f = true
        M.times{|l|
            f &&= a[y + l][x, M] == b[l]
        }
        break if f
    }
    break if f
}
if f
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int n,a[201];
long long ans=0;
int main()
{
	scanf("%d",&n);
	n*=2;
	for (int i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for (int i=1;i<=n;i+=2)
	  ans+=a[i];
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
	using namespace std; 
	#define max(a, b) (a < b ? b : a) 
	#define min(a, b) ((a > b) ? b : a) 
	#define mod 1e9 + 7 
	#define FOR(a, c) for (int(a) = 0; (a) < (c); (a)++) 
	#define FORL(a, b, c) for (int(a) = (b); (a) < (c); (a)++) 
	#define FORR(a, b, c) for (int(a) = (b); (a) > (c); (a)--) 
	#define INF 1000000000000000003 
	typedef long long int ll; 
	typedef vector<int> vi; 
	typedef vector<long long int> vl; 
	typedef pair<int, int> pi; 
	typedef pair<long long int, long long int> pl; 
	#define F first 
	#define S second 
	#define pb push_back 
	#define POB pop_back 
	#define mp make_pair 
	

	int main()
	 {ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
		string s;
		cin>>s;
		if(s[s.size()-1]=='s')
		s+="es";
		else
		s+='s';
		cout<<s<<endl;
    

		
	return 0;
	}






Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            List<ClsDis> lstDis = new List<ClsDis>();            
            for (int i = 0; i < 5; i++)
            {
                string sS = System.Console.ReadLine().Trim();
                ClsDis oneUsr = new ClsDis();
                oneUsr.iL = int.Parse(sS);
                oneUsr.iD = 10 - (oneUsr.iL % 10 == 0 ? 10 : oneUsr.iL % 10);
                lstDis.Add(oneUsr);
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            lstDis.Sort(delegate (ClsDis mca1, ClsDis mca2) { return (int)(mca1.iD - mca2.iD); });        // 差分の昇順
            int iSum = 0;
            for (int i = 0; i < lstDis.Count - 1; i++)
            {
                iSum += lstDis[i].iL + lstDis[i].iD;
            }
            iSum += lstDis[lstDis.Count - 1].iL;

            // 出力
            System.Console.WriteLine("{0}", iSum.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

        private class ClsDis
        {
            public int iL { get; set; } = 0;    // 時間
            public int iD { get; set; } = 0;    // 10分単位の差分
        }

}


Measured memory_bytes: 13396