akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#include <iomanip>
#define endl "\n"
#define debug(x) cout << #x << " : " << x << endl;
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0);
typedef long long ll;
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
}

Measured memory_bytes: 3604
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
  int k = readln.chomp.to!int;
  alias Node = Tuple!(int, "cost", int, "value");
  alias RBT = RedBlackTree!(Node, (a, b) => a < b, false);
  RBT queue = new RBT();
  queue.insert(Node(0, k));
  bool[int] set;
  while (queue.length) {
    Node node = queue.front;
    queue.removeFront;
    // stderr.writeln(node);
    if (node.value == 0) {
      node.cost.writeln;
      return;
    }
    if (node.value in set) {
      continue;
    }
    set[node.value] = true;
    foreach (x; 0..10) {
      int v = (node.value + k * x);
      Node next;
      next.value = v / 10;
      next.cost = node.cost + (v % 10);
      // stderr.writeln("\tx : ", x, " : ", next);
      queue.insert(next);
    }
  }
}


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

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

        //しゃくとり法
        int r = 0;
        ll sum = 0;
        ll res = 0;
        rep(l,n) {
                while(r < n && (sum + v.at(r)) == (sum ^ v.at(r))) {
                        sum += v.at(r);
                        r++;
//                        cout << l << " " << r << endl;
                }

                res += r - l;
                if(l == r) r++;
                else sum -= v.at(l);
        }

        cout << res << endl;


}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <sstream>
 
int main()
{
	int counter[26];

	for (int n = 0; n < 26; ++n)
		counter[n] = 0;

	char ch;
	while (std::cin >> ch)
	{
		const int c = ch;

		if (64 <= c && c <= 90)
			++counter[c - 65];
		else if (97 <= c && c <= 122)
			++counter[c - 97];
	}

	for (int n = 0; n < 26; ++n)
	{
		std::cout << (char)(n + 97) << " : " << counter[n] << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3116
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            if (map.containsKey(s)) {
                map.put(s, map.get(s) + 1);
            } else {
                map.put(s, 1);
            }
        }
        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            String s = sc.next();
            if (map.containsKey(s)) {
                map.put(s, map.get(s) - 1);
            } else {
                map.put(s, -1);
            }
        }
        int max = -100;
        for (Map.Entry<String, Integer> e : map.entrySet()) {
            max = Math.max(e.getValue(), max);
        }

        System.out.println(Math.max(max, 0));
    }
}

Measured memory_bytes: 25044
from sys import stdin

n, k = [int(x) for x in stdin.readline().rstrip().split()]

okashimap = {}

for i in range(1,k+1):
    d = int(stdin.readline().rstrip())
    an = list(map(int, input().split()))
    for j in range(d):
        okashimap[an[j]] = True 

trick = [x for x in range(1,n+1) if x not in okashimap.keys()]
print(len(trick))


Measured memory_bytes: 67152
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N;
	int ans = 1;
	string S;

	cin >> N >> S;

	rep(i, N - 1) {
		if (S[i] != S[i + 1]) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long int X;
  cin >> X;
  long int fivehund;
  long int five;
  fivehund = X/500;
  //cout << fivehund << endl;
  five = (X-fivehund*500)/5;
//  cout << five << endl;
  cout << fivehund*1000 + five*5 << endl;

}

Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
#define erase(i) erase(i, 1)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
template<typename T> void remove(std::vector<T>& vector, unsigned int index){vector.erase(vector.begin() + index);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;


signed main()
{
    int n;
    cin >> n;
    int no[] = {1,2,3,5,6,9,10,13,17};
    if(n<=17)
    {
        rep(i,9)
        {
            if(n == no[i])
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i,j,count=0;
  scanf("%d",&n);
  int h[n+1];
  for(i=0;i<n;i++)
    scanf("%d",&h[i]);
  for(i=0;i<n;i++){
    int check=0;
    for(j=0;j<i;j++){
      if(h[j]>h[i])
        check=1;
    }
    if(check==0)
      count++;
  }
  printf("%d\n",count);
  return 0;
}


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

//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 100000000;

int main() {
	string s;
	cin >> s;
	int count[27] = {};
	bool flag = 0;
	REP(i, s.size()) {
		count[s[i] - 'a']++;
		if (count[s[i] - 'a'] > 1)flag = 1;
	}
	if (flag) { print("no"); }
	else { print("yes"); }
	return 0;
}

Measured memory_bytes: 256
n = int(input())

if n <= 6:
    ans = 1
elif 7 <= n <= 11:
    ans = 2
else:
    a = n // 11
    b = n % 11
    if b == 0:
        ans = a*2
    elif 1 <= b <= 6:
        ans = a*2 + 1
    else:
        ans = a*2 + 2

print(ans)

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

int main(int argc, char* argv[])
{
    vector<string> result;
    auto GetGrade = [&](const double& m, const double& f, const double& r)->string{
        if(m==-1 || f==-1 || m+f<30) return "F";
        if(m+f>=80) return "A";
        if(m+f<80 && m+f>=65) return "B";
        if((m+f<65 && m+f>=50) || (r>=50)) return "C";
        if(m+f<50 && m+f>=30) return "D";
    };
    while(1)
    {
        double m, f, r;
        cin >> m >> f >> r;
        if(m==-1 && f==-1 && r==-1) break;
        result.push_back(GetGrade(m,f,r));
    }
    for (auto var : result)
    {
        cout << var << endl;
    }


    return 0;
}



Measured memory_bytes: 3180
#N = int(input())
#S = str(input())
#A, B = map(int, input().split())
#C = list(map(int, input().split()))

N, K = map(int, input().split())
S = str(input())

d = ["A", "B", "C"]
e = ["a", "b", "c"]

for i in range(N):
  if i == K - 1:
    inde = d.index(S[i])    
    print(e[inde], end = "")
  else:
    print(S[i], end = "")


Measured memory_bytes: 9168
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ


int main()
{
    int n;
    cin >> n;
    int k;
    cin >> k;
    char s[100];
    cin >> s;

    if (s[k - 1] == 'A') {
        s[k - 1] = 'a';
    }
    else if (s[k - 1] == 'B') {
        s[k - 1] = 'b';
    }
    else if (s[k - 1] == 'C') {
        s[k - 1] = 'c';
    }
    
    cout << s << endl;

    return 0;
}

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

int n,tb[11][11];
bool ch[11][11];

void check_ver(int x, int y){
	for(int i = 1; i <= 9; i++){
		if(i != x && tb[i][y] == tb[x][y]){
			ch[x][y] = ch[i][y] = true;
		}
	}
}
void check_hol(int x,int y){
	for(int i = 1; i <= 9; i++){
		if(i != y && tb[x][i] == tb[x][y]){
			ch[x][y] = ch[x][i] = true;
		}
	}
}
void check_blk(int x,int y){
	for(int i = ((x-1)/3)*3+1; i <= ((x-1)/3)*3+3; i++){
		for(int j = ((y-1)/3)*3+1; j <= ((y-1)/3)*3+3; j++){
			if(!(i == x && j == y) && tb[x][y] == tb[i][j]){
				ch[x][y] = ch[i][j] = true;
			}
		}
	}
}

int main(){
	scanf("%d",&n);
	for(int tm = 0; tm < n; tm++){
		for(int i = 1; i <= 9; i++){
			for(int j = 1;j <= 9; j++){
				scanf("%d",&tb[i][j]);
				ch[i][j] = false;
			}
		}
		for(int i = 1; i <= 9; i++){
			for(int j = 1;j <= 9; j++){
				check_ver(i,j);
				check_hol(i,j);
				check_blk(i,j);
			}
		}
		if(tm != 0){
			puts("");
		}
		for(int i = 1; i <= 9; i++){
			for(int j = 1;j <= 9; j++){
				printf("%c%d",ch[i][j] ? '*' : ' ',tb[i][j]);
			}
			puts("");
		}

	}

	return 0;
}



Measured memory_bytes: 3204
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int):
    print(A ^ B ^ C)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
using System;

namespace abc060_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            string strA = input[0];
            string strB = input[1];
            string strC = input[2];

            if (strA.EndsWith(Convert.ToString(strB[0])))
            {
                if (strB.EndsWith(Convert.ToString(strC[0])))
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
            else
            {
                Console.WriteLine("NO");
            }


        }
    }
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int MAX_N=100,MAX_M=100,INF=1e8;

struct P{
	int h,r;
	P(){};
	P(int h,int r):h(h),r(r){};
	bool operator < (const P &a)const{
		if (h!=a.h){
			return h<a.h;
		}
		return r>a.r;
	}
};

int N,M;
P pa[MAX_N+MAX_M];

int dp[MAX_N+MAX_M+1];

int main(){
	do{
		scanf("%d",&N);
		if (N){
			int h,r;
			REP(i,N){
				scanf("%d %d",&h,&r);
				pa[i]=P(h,r);
			}
			scanf("%d",&M);
			REP(i,M){
				scanf("%d %d",&h,&r);
				pa[N+i]=P(h,r);
			}
			sort(pa,pa+N+M);
			fill(dp,dp+N+M+1,INF);
			REP(i,N+M){
				int ra=pa[i].r;
				*lower_bound(dp,dp+N+M+1,ra)=ra;
			}
			printf("%d\n",(int)(lower_bound(dp,dp+N+M+1,INF)-dp));
		}
	}while (N);
	return 0;
}

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

char field[105][105];
int dp[105][105];
int main() {
	
	int h, w;
	scanf("%d %d\n", &h, &w);
	for (int i=1; i <= h; i++) {
		scanf("%s", &field[i][1]);
	}
	for (int i=0; i <= h; i++) {
		dp[i][0] = 987654321;
		field[i][0] = '.';
	}
	field[0][1] = '.';
	for (int i=2; i <=w; i++) {
		dp[0][i] = 987654321;
		field[0][i] = '.';
	}
	for (int i=1; i<=h; i++) {
		for (int j=1;j <= w ;j++) {
			auto& fup = field[i-1][j];
			auto& here = field[i][j];
			auto& fleft = field[i][j-1];
			int up = dp[i-1][j] + (fup == '.' && here == '#' ? 1 : 0);
			int lef = dp[i][j-1] + (fleft == '.' && here == '#' ? 1 : 0);
			dp[i][j] = min(up, lef);
			//dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + (field[i][j] == '#' ? 1 : 0);
		}
	}
	printf("%d\n", dp[h][w]);
	return 0;
	//debug
	for (int i=0; i <=h; i++) {
		for (int j=0; j <=w; j++) {
			printf("%d ", dp[i][j]);
		}
		putchar('\n');
	}
	for (int i=1; i <= h; i++) {
		printf("%s\n", &field[i][1]);
	}
	//debug
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

void solve(void){
    int N; string S;
    cin >> N >> S >> S;
    ll ans = (S[0] == S[1] ? 6LL : 3LL);
    int i = (S[0] == S[1] ? 2 : 1), c = S[0] == S[1];
    while(i < N) {
        if (S[i] == S[i+1]) {
            if (c) ans = (ans * 3) % MOD;
            else ans = (ans * 2) % MOD;
            i += 2;
            c = 1;
        }
        else {
            if(!c) ans = (ans * 2) % MOD;
            c = 0;
            i++;
        }
    }
    cout << ans << '\n';
}

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


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

s=[]

def f(k):
  if k%3==0:
    return True
  elif k%5==0:
    return True
  else:
    return False

r="APPROVED"
  
for i in a:
   if i%2==0:
      if f(i)==False:
        r="DENIED"
        
print(r)
        

Measured memory_bytes: 3060
// Probably getting a WA/Tle
// Still trying
// Apna time ayega

#include<bits/stdc++.h>
#define FastRead ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0);cin.tie(0),cout.tie(0);
#define ll long long int
#define Endl cout<<"\n"
using namespace std;
int main()
{
    FastRead;
    ll i,j,n,k,t,a,b,c,x,y,r=0,s=0,p=0;
    string st,st1;
    cin>>n>>k>>a>>b>>c;
    cin>>st;
    for(i=0; i<k; i++)
    {
        if(st[i]=='r')
        {
            st1+='p';
            p++;
        }
        else if(st[i]=='s')
        {
            st1+='r';
            r++;
        }
        else
        {
            st1+='s';
            s++;
        }
    }
    for(i=k; i<n; i++)
    {
        if(st[i]=='s' && st1[i-k]!='r')
        {
            r++;
            st1+='r';
        }
        else if(st[i]=='s' && st1[i-k]=='r')
        {
            st1+='t';
        }
        else if(st[i]=='p' && st1[i-k]!='s')
        {
            st1+='s';
            s++;
        }
        else if(st[i]=='p' && st1[i-k]=='s')
        {
            st1+='t';
        }
        else if(st[i]=='r' && st1[i-k]!='p')
        {
            p++;
            st1+='p';
        }
        else if(st[i]=='r' && st1[i-k]=='p')
        {
            st1+='t';
        }

    }
    //cout<<r<<" "<<p<<" "<<s<<endl;
    cout<<(r*a)+(s*b)+(p*c)<<endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<tuple>
#include<sstream>
#include<functional>
#include<list>
#include<queue>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
typedef pair<ll, ll> p;
typedef vector<int> vec;
using Graph = vector<vector<int>>;
using graph = vector<vector<ll>>;


const ll inf = (1LL << 31) - 1;
const long long MOD = 1000000007;


int main() {
    int n;
    cin >> n;
    ll ans = 0;
    ll memo;
    cin >> memo;
    rep(i, n-1) {
        ll a;
        cin >> a;
        if (memo <= a)memo = a;
        else ans += (memo - a);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568
import heapq
def main():
    N, M = map(int, input().split())
    l = []
    for _ in range(N):
        a, b = map(int, input().split())
        if a > M:
            continue
        l.append((a,b))
    l.sort(key=lambda x: x[0])
    t = []
    i = 0
    r = 0
    for d in range(1, M+1):
        while i < len(l):
            a, b = l[i]
            if a <= d:
                heapq.heappush(t, -b)
            else:
                break
            i += 1
        if not t:
            continue
        r -= heapq.heappop(t)
    return r
print(main())


Measured memory_bytes: 20436
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ll long long
#define ss second
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(v) (v).begin(),(v).end()
#define maxv(v) max_element(all(v))
#define minv(v) min_element(all(v))
#define bclock auto start=high_resolution_clock::now(); 
#define eclock auto stop = high_resolution_clock::now(); 
#define calctime auto duration=duration_cast<milliseconds>(stop-start); cout<<"\nTime "<<duration.count()<<endl;
using namespace std;
using namespace std::chrono;
ll maxl(ll a,ll b) { if(a>b) return a; return b; }
ll minl(ll a,ll b) { if(a<b) return a; return b; }
int main() {
   IOS
   int n;
   cin>>n;
   cout<<pow(n,3);
   return 0;
}


Measured memory_bytes: 512
import math

n, k = map(int, input().split())
res = 0
for i in range(1, n+1):
    a = k / i
    b = format(math.ceil(a) - 1, 'b')
    num = 0 if b == '0' else len(b)
    res +=  (1/n) *  (1/2)**num
print(res)

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

#define rep(i, u) for (int i = 0; i < u; i++)

using ll = long long;
using ull = unsigned long long;

int main() {
  int n, d, ans = 0;
  string x, y;
  cin >> n >> d;
  rep(i, n) {
    cin >> x >> y;
    if (x[0] == '-') x = x.substr(1, x.size());
    if (y[0] == '-') y = y.substr(1, y.size());
    if (d >= sqrt(pow(stoi(x), 2) + pow(stoi(y), 2))) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3748
from itertools import product
S = input()
N = int(S)
X = len(S)+1

ans = 0
for i in range(3,X):
  for pat in product('357', repeat=i):
    if len(set(pat)) < 3:
      continue
    if int("".join(pat)) <= N:
      ans += 1
      
print(ans)

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

int main() {
  int n, k, q;
  cin >> n >> k >> q;

  int score[n];
  rep (i, n) score[i] = k-q;

  rep (i, q) {
    int a;  cin >> a;
    a--;
    score[a]++;
  }

  rep (i, n) {
    if (score[i] <= 0) puts("No");
    else puts("Yes");
  } 

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
main(void){
    int h, n, s=0;
    cin>>h>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        s+=a[i];
    }
    cout<<( s>=h?"Yes":"No" );
}


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

int main(){
  int a,b;
  cin >> a>>b;
  rep(i,1100) {
    if(i*8/100==a&&i*10/100==b){
      cout << i <<endl;
      return 0;
    }
  }
  cout <<-1<<endl;
}


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

using ll = long long;
#define int long long

using namespace std;

//0 -> a-1
#define rep(i, a) for (int i = 0; (i) < (int)(a); (i)++)
//a -> b-1
#define reps(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++)
//a-1 -> 0
#define rrep(i, a) for (int i = (int)a - 1; (i) >= 0; (i)--)
//a-1 -> b
#define rreps(i, a, b) for (int i = (int)(a)-1; (i) >= (int)(b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
//next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
(v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v) \
	sort(all(v)); \
	(v).erase(unique(all(v)), v.end())
#define CIN(type, x) \
	type x;          \
	cin >> x
#define YES(f) if ((f)) {cout << "YES" << endl;} else {cout << "NO" << endl;}
#define Yes(f) if ((f)) {cout << "Yes" << endl;} else {cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
//b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
//c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(12)
#define RS resize
#define CINV(v, N)             \
	do                         \
	{                          \
		v.RS(N);               \
		rep(i, N) cin >> v[i]; \
	} while (0);

#define RCINV(v, N)             \
	do                          \
	{                           \
		v.RS(N);                \
		rrep(i, N) cin >> v[i]; \
	} while (0);
#define MOD 1000000007

template <class T>
inline T GET()
{
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
	string s;
	cin >> s;
	int l = s.length();
	int res = 0;
	rep(i, l) {
		bool f = true;
		reps(j, i, l) {
			bool t = false;
			reps(k, i, j+1) {
				t |= s[j] == 'A';
				t |= s[j] == 'C';
				t |= s[j] == 'G';
				t |= s[j] == 'T';
				f &= t;
			}
			if (f) chmax(res, j-i+1);
		}
	}
	cout << res << endl;
}

void solve()
{
}



Measured memory_bytes: 256
//01BFS書くの面倒くさいのでlogで祈る
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int INF = 1e+9;
int h, w;
int sy, sx;
int dy, dx;
string s[1000];
int dp[1000][1000];

signed main() {
	int i, j;
	
	cin >> h >> w;
	cin >> sy >> sx; sy--; sx--;
	cin >> dy >> dx; dy--; dx--;
	rep(i, h) cin >> s[i];
	rep(i, h) rep(j, w) dp[i][j] = INF;
	
	typedef tuple<int, int, int> T;
	priority_queue<T, vector<T>, greater<T>> que;
	
	que.push(T(0, sy, sx));
	while (!que.empty()) {
		T now = que.top(); que.pop();
		int cst = get<0>(now);
		int y = get<1>(now);
		int x = get<2>(now);
		
		if (dp[y][x] <= cst) continue;
		dp[y][x] = cst;
		if (y == dy && x == dx) break;
		
		for (i = -2; i <= 2; i++) {
			for (j = -2; j <= 2; j++) {
				int ny = y + i;
				int nx = x + j;
				if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
				if (s[ny][nx] == '#') continue;
				int ncst = cst;
				if (abs(i) + abs(j) > 1) ncst++;
				if (dp[ny][nx] <= ncst) continue;
				que.push(T(ncst, ny, nx));
			}
		}
	}
	
	if (dp[dy][dx] >= INF) cout << -1 << endl;
	else cout << dp[dy][dx] << endl;
	
	return 0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int x; scanf("%d", &x); x--;

	while(x++) {
		bool is_prime = true;
		for(i64 i = 2; i * i <= x; i++) {
			if(x % i) continue;

			is_prime = false;
			break;
		}

		if(is_prime) break;
	}
	
	printf("%d\n", x);
	return 0;
}


Measured memory_bytes: 256
N, A, B, C = [int(a) for a in input().split(" ")]
ls = [int(input()) for i in range(N)]
tab = [([float("inf")]*N, ref) for ref in (A, B, C)]
INF = float("inf")
from heapq import heappush, heappop, heapreplace
maxtarg = max(A, B, C)

# O(n)
def solve(ls):
    n = len(ls)
    qs = [[(-INF, -1)]*3 for i in range(3)]
    # 3*n times
    for ref, q in zip((A, B, C), qs):
        for i in range(n):
            val = -abs(ref-ls[i])
            if q[0][0] < val:
                heapreplace(q, (val, i))
    ans = INF
    # 9 times
    for a, i in qs[0]:
        for b, j in qs[1]:
            for c, k in qs[2]:
                if i!=j and j!=k and k!=i:
                    ans = min(ans, -(a+b+c))
    return ans
dic = {}
def dfs(ls):
    key = tuple(sorted(ls))
    if key in dic:
        return dic[key]
    n = len(ls)
    if n < 3: return INF
    ans = solve(ls)
    for i in range(n-1):
        for j in range(i+1,n):
            tmp = ls[i]+ls[j]
            if min(maxtarg-ls[i], maxtarg-ls[j]) < 10:
                continue
            ls2 = ls[:i]+ls[i+1:]
            ls2[j-1] = tmp
            ans = min(ans, 10+dfs(ls2))
    dic[key] = ans
    return ans

print(dfs(ls))


Measured memory_bytes: 3900
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
const ll mod = 1000000007;
int n,k,s;
int main(){
	cin>>n>>k>>s;
	if(s != 1000000000){
		rep(i,k) printf("%d\n",s);
		rep(i,n-k) printf("%d\n",1000000000);
	}
	else{
		rep(i,k) printf("%d\n",s);
		rep(i,n-k) printf("%d\n",1);
	}
}

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

int main(){
    long long H,W;
    cin >> H >> W;
    bool iswrite=false;

    int ncases=6;
    long long S[ncases];

    long long Vline, Hline;
    long long Smax, Smin, Smid;
    long long Stmp, ans;

    // case 1 vertical
    if( W%3==0 ){
        cout << 0 << endl;
        return 0;
    }else if( W%3!=0 ){
        S[0]=H;
        if(W<3){
            S[0]=W*H;
        }
    }
    if(iswrite) cout << "case 1 vertical S= " << S[0] << endl;

    // case 2 horizontal
    if( H%3==0 ){
        cout << 0 << endl;
        return 0;
    }else if( H%3!=0 ){
        S[1]=W;
        if(H<3){
            S[1]=W*H;
        }
    }
    if(iswrite) cout << "case 2 horizontal S= " << S[1] << endl;

    // case 3 ver(large) + hori
    Vline = (long long) W/3 + 1;
    Smax = H*Vline;
    Hline = (long long) H/2;
    Smin = (W-Vline)*Hline;
    S[2]= Smax-Smin;
    if(iswrite) cout << "case 3 V(large)-H, S= " << S[2] << endl;

    // case 4 ver(small) + hori
    Vline = (long long) W/3;
    Smax = H*Vline;
    Hline = (long long) H/2;
    Smin = (W-Vline)*Hline;
    Smid = (W-Vline)*(H-Hline);
    Stmp = Smax;
    Smax = max(Smax,Smid);
    Smin = min(Stmp,Smin);
    S[3]= Smax-Smin;
    if(iswrite) cout << "case 4 V(small)-H, S= " << S[3] << endl;

    // case 5 hori(large) + ver
    Hline = (long long) H/3 + 1;
    Smax = W*Hline;
    Vline = (long long) W/2;
    Smin = (H-Hline)*Vline;
    //cout << "Smax Smin " << Smax << " " << Smin << endl;
    S[4]= Smax-Smin;
    if(iswrite) cout << "case 5 H(large)-V, S= " << S[4] << endl;

    // case 6 hori(small) + ver
    Hline = (long long) H/3;
    Smax = W*Hline;
    Vline = (long long) W/2;
    Smin = (H-Hline)*Vline;
    Smid = (H-Hline)*(W-Vline);
    Stmp = Smax;
    Smax = max(Smax,Smid);
    Smin = min(Stmp,Smin);
    //cout << "Smax Smin " << Smax << " " << Smin << endl;
    S[5]= Smax-Smin;
    if(iswrite) cout << "case 5 H(small)-V, S= " << S[5] << endl;

    for(int i=0; i<ncases; i++){
        if(i==0){
            ans = S[i];
        }else if( ans > S[i] ){
            ans = S[i];
        }
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define e18 (long long)(1e18)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}


void solve()
{
  ll n; cin >> n;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  vector<ll> a(n); rep(i, n) cin >> a[i];
  unsigned long long  ans = 1;
  bool ok = true;
  rep(i, n) {
    if(a[i] == 0) {
      cout << 0 << endl;
      return;
    }
    if(ans > e18 / a[i]) ok = false;
    ans *= a[i];

  }
  if(!ok) {
    cout << -1 << endl;
    return;
  }

  cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


Measured memory_bytes: 4044
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main()
{
  int N; cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  int ans = accumulate(A.begin() + 1, A.end(), A[0], __gcd<long long>);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


from collections import deque


def main():
    X, Y, A, B, C = map(int, input().split())
    p = sorted(list(map(int, input().split())), reverse=True)
    q = sorted(list(map(int, input().split())), reverse=True)
    r = sorted(list(map(int, input().split())), reverse=True)

    pp = p[:X]
    qq = q[:Y]

    li = sorted(pp + qq + r, reverse=True)
    M = sum(li[:X+Y])

    print(M)



if __name__ == '__main__':
    main()

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

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	unsigned long long a, b, x, ans;
	
	cin >> a >> b >> x;
	
	ans = b / x - (a == 0 ? 0 :(a - 1) / x) + (a == 0 ? 1 : 0);
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
n=int(input())
xl=[list(map(int,input().split())) for i in range(n)]

xl.sort(key=lambda x: x[0])

ans=0
for i in range(1,n):
    if xl[i-1][0]+xl[i-1][1]>xl[i][0]-xl[i][1]:
        ans+=1
        if xl[i-1][0]+xl[i-1][1]<xl[i][0]+xl[i][1]:
            xl[i]=xl[i-1]
print(n-ans)

Measured memory_bytes: 29096
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println(x-a-(((x-a)/b)*b));
    }
}


Measured memory_bytes: 23124
#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, x;
vector<int> list[maxN];
int dp[maxN];

void dfs(int node) {
    if(list[node].empty()) {
        dp[node] = 0;
        return;
    }

    vector<int> aux = {};
    for (auto to : list[node]) {
        dfs(to);
        aux.pb(dp[to]);
    }

    sort(aux.begin(), aux.end());
    int vv = aux.size();

    for (auto e : aux) {
        dp[node] = max(dp[node], e + vv);
        vv--;
    }
}

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

    scanf("%d", &n);
    for (i = 2; i <= n; i++) {
        scanf("%d", &x);
        list[x].pb(i);
    }

    dfs(1);
    printf("%d", dp[1]);



    return 0;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;

bool guu(string S){
 int N = sz(S);
  if(N%2 ==1) return false;
  rep(i,N/2){
	if(S[i]!=S[i+(N/2)]) return false;
  }
  return true;
}


int main() {
string S;
  in(S);
  int N = sz(S);
  int ans =1;
  rep(i,N-1){
    int k = sz(S);
    S.erase(k-1);
    if(guu(S)){
      out(N-ans);
      return 0;
    }
    else ans++;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> c(n);
    REP(i, n) c[i] = 0;
    REP(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        c[a] += 1;
        c[b] += 1;
    }
    REP(i, n){
        if(c[i] % 2 == 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 640
unittest
{
	assert( [ "5", "4 4 9 7 5" ].solve == 5 );
	assert( [ "6", "4 5 4 3 3 5" ].solve == 8 );
	assert( [ "10", "9 4 6 1 9 6 10 6 6 8" ].solve == 39 );
	assert( [ "2", "1 1" ].solve == 0 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto ls = input.front.split.to!( long[] );
	
	auto ans = 0L;
	ls.sort;
	foreach( i, a; ls )
	{
		foreach( j, b; ls[ i + 1 .. $ ] )
		{
			foreach( c; ls[ i + j + 1 .. $ ] )
			{
				ans += ( a != b && a != c && b != c && c < a + b );
			}
		}
	}
	return ans;
}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    string s;
    cin >> s;
    unsigned long ans{0};
    for(unsigned long i{1}; i + 1 < N; ++i)if(s[i - 1] == 'A' && s[i] == 'B' && s[i + 1] == 'C')++ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M  =2e5+23;
char v[M];
set<int> s;
int T,n;
int dp[M][4];
int a[M][3];
int go (int i ,int last) {
    if (i==n) return 0;
    int &ret = dp[i][last];
        if (ret+1)return ret;
    ret = -1;
    for (int j=0;j<3;j++) {
        if (j==last)continue;
        ret = max(ret,go(i+1,j)+a[i][j]);
    }
    return ret;
}
int main () {
    memset(dp,-1,sizeof dp);
    scanf("%d",&n);
    for (int i=0;i<n;i++)
        for (int j=0;j<3;j++)
            scanf("%d",&a[i][j]);
    cout <<go (0,3);
}


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

    using namespace std;

    #define pb push_back
    #define fr first
    #define sc second
    #define ll long long

    ll a, b, c, k;

    int main() {

        cin >> a >> b >> c >> k;

        if(k % 2 == 1){
            cout << b - a;
        }
        else {
            cout << a - b;
        }

        return 0;
    }


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

void DP(int i, int j, long long dp[101][101], int r[], int c[]){
    if(i == j) dp[i][j] = 0;
    else if (j - i == 1){
        dp[i][j] = r[i] * c[i] * c[j];
    } else {
        int tmp = i;
        dp[i][j] = dp[i][tmp] + dp[tmp+1][j] + r[i] * r[tmp+1] * c[j];
        // cout <<  "i: "<< i <<" tmp: " << tmp <<" " << r[i] * r[tmp+1] * c[j] <<endl;
        tmp++;
        while(tmp != j){
            dp[i][j] = min(dp[i][j], dp[i][tmp] + dp[tmp + 1][j] + r[i] * r[tmp+1] * c[j]);
            // cout <<  "i: "<<i<<" tmp: " << tmp <<" " << r[i] * r[tmp+1] * c[j] <<endl;
            tmp++;
        }
    }
    
    // cout << "i, j: " << i << ", " << j << " " <<  dp[i][j] << endl;
}

void solve(){
    int n; cin >> n;
    int r[n+1], c[n+1];
    r[0] = 0; c[0] = 0;
    for(int i = 1; i <= n; ++i) {
        cin >> r[i] >> c[i];
    }
    long long dp[101][101] = {};
 
    for(int i = 1; i < n; i ++){
        int tmp = 1;
        for(int j = i + tmp; j <= n; j++, tmp++){
            DP(tmp, j, dp, r, c);
        }
    }
    cout << dp[1][n] << endl;
}

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


Measured memory_bytes: 3208
N=int(input())
A=[]
dp=[[0 for j in range(N)] for i in range(2)]
for i in range(2):
    A.append(list(map(int,input().split())))
dp[0][0]=A[0][0]
dp[1][0]=dp[0][0]+A[1][0]
for i in range(1,N):
    dp[0][i]=dp[0][i-1]+A[0][i]
    dp[1][i]=dp[1][i-1]+A[1][i]
    dp[1][i]=max(dp[1][i],dp[0][i]+A[1][i])
print(dp[1][N-1])


Measured memory_bytes: 38256
#include <stdio.h>

int main(void){
  int N,i;
  scanf("%d",&N);
  for(i=N;i<1000;i++){
    if(i/100 == i%100/10 && i%100/10==i%10) break;
  }
  printf("%d\n",i);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (i % 2 == 0 || i == 0) {
						if (j % 2 == 0||j==0) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					else {
						if (j % 2 == 0||j==0) {
							System.out.print(".");
						} else {
							System.out.print("#");
						}
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}


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

class Program {
    static void Main(string[] args) {
        string a = Console.ReadLine();
        string b = Console.ReadLine();
        if (a == b) {
            Console.WriteLine("EQUAL");
            return;
        }
        if (a.Length > b.Length) {
            Console.WriteLine("GREATER");
            return;
        } else if (a.Length < b.Length) {
            Console.WriteLine("LESS");
            return;
        } else {
            string[] f = new string[2];
            f[0] = a;
            f[1] = b;
            Array.Sort(f);
            if (f[0] == b) {
                Console.WriteLine("GREATER");
            } else {
                Console.WriteLine("LESS");
            }
        }
    }
}

Measured memory_bytes: 11360
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

void Main() {
	int a, p; cin >> a >> p;
	cout << ((3 * a) + p) / 2 << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int cnt[5]={0},n;
    cin>>n;
    for (int i=0;i<n;i++){ 
    	string s; cin>>s; 
    	if (s[0]=='M') cnt[0]++; 
    	if (s[0]=='A') cnt[1]++; 
    	if (s[0]=='R') cnt[2]++; 
    	if (s[0]=='C') cnt[3]++; 
    	if (s[0]=='H') cnt[4]++; 
    } 
    int ans=0;
    for (int i=0;i<=2;i++){
    	for (int j=i+1;j<=3;j++){
    		for (int k=j+1;k<=4;k++){
    			ans += cnt[i]*cnt[j]*cnt[k];
    		}
    	}
    }
    cout << ans << endl;
}

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


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


li n;
li a[100100];

int main() {
    cin >> n;
    rin{
        cin >> a[i];
    }
    sort(a, a + n);

    li res = 0;
    if (n % 2 == 0) {
        li now = a[n / 2 - 1];
        rin{
            res += abs(a[i] - now) * 2;
        }
        res -= abs(now - a[n / 2]);
    } else {
        // 高い側が過半数
        li now = a[n / 2 - 1];
        li tres = 0;
        rin{
            tres += abs(a[i] - now) * 2;
        }
        tres -= (abs(a[n / 2] - now) + abs(a[n / 2 + 1] - now));
        res = tres;
        // 低い側が過半数
        now = a[n / 2 + 1];
        tres = 0;
        rin{
            tres += abs(a[i] - now) * 2;
        }
        tres -= (abs(a[n / 2] - now) + abs(a[n / 2 - 1] - now));
        res = max(res, tres);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
mod = 10**9 + 7
dp = [0]*((N+1)*(M+1))
dp[1] = 1
for i in range(1, N+1):
    s = input().strip()
    for j in range(1, M+1):
        if s[j-1] == ".":
            dp[i*(M+1)+j] = (dp[(i-1)*(M+1) + j] + dp[i*(M+1) + j-1])%mod
print(dp[N*(M+1)+M])


Measured memory_bytes: 50412