akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;

  for (int i = 0; i < n-2; i++) {
    if (s[i] != s[i+1] && s[i+1] != s[i+2]) {
      s[i+1] = s[i];
      k--;
    }
    if(k == 0) {
      break;
    }
  }

  if (k > 0) {
    for (int i = 1; i < n-1; i++) {
      if (s[i] != s[i+1]) {
        bool flag1 = true;
        int j = 0;
        while (flag1) {
          s[i+1+j] = s[i+j];
          j++;
          if (1+i+j >= n) {
            flag1 = false;
            break;
          }
          if (s[i+1+j] == s[i+j]) {
            flag1 = false;
          }
        }
        k--;
      }
      if(k == 0) {
      break;
      }
    }
  }

  if (k > 0) {
    if (s[0] == 'L') s[0] = 'R';
    else s[0] = 'L';
    int j = 0;
    while (s[j+1] != s[j]){
      s[j+1] = s[j];
      j++;
      if (j+1 >= n) break;
    }
  }

  int ans = 0, tmp = 0;
  for (int i = 0; i < n-1; i++) {
    if (s[i] == s[i+1]){
      tmp++;
    }
    else {
      ans += tmp;
      tmp = 0;
    }
  }
  ans += tmp;

  cout << ans << endl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define maxn 100005

int main()
{
    int a,b,c,x,y,mm,mx;
    long long s1=0,s2=0,s3=0;
    scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
    mm=min(x,y);
    mx=max(x,y);
    s1=mx*2*c;
    s2=mm*2*c;
    if(x>y) s2+=(x-y)*a;
    else s2+=(y-x)*b;
    s3=x*a+y*b;
    cout<<min(min(s1,s2),s3)<<"\n";
    return 0;
}


Measured memory_bytes: 384
/* - - - - - - - - - - - - - - -
	User : 		VanishD
	problem :
	Points : 	
- - - - - - - - - - - - - - - */
# include <bits/stdc++.h>
# define 	ll 		long long
using namespace std;
const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
int read(){
	int tmp = 0, fh = 1; char ch = getchar();
	while (ch < '0' || ch > '9'){ if (ch == '-') fh = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9'){ tmp = tmp * 10 + ch - '0'; ch = getchar(); }
	return tmp * fh;
}
const int N = 100010;
ll mp[520][520];
int p[N], pnum;
bool use[N];
int n;
void prep(int n){
	use[1] = true;
	for (int i = 2; i <= n; i++){
		if (use[i] == false) p[++pnum] = i;
		for (int j = 1; 1ll * i * p[j] <= n && j <= pnum; j++){
			use[p[j] * i] = true;
			if (i % p[j] == 0) break;
		}
	}
}
int main(){
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read();
	prep(100000);
	for (int i = 1; i <= n + 2; i++)
		for (int j = 1; j <= n + 2; j++)
			if ((i + j) % 2 == 0){
				int p1 = (i + j) / 2, p2 = (i - j) / 2 + 760;
				mp[i][j] = p[p1] * p[p2];
			} 
	for (int i = 2; i <= n + 1; i++)
		for (int j = 2; j <= n + 1; j++)
			if ((i + j) % 2 == 1){
				mp[i][j] = mp[i - 1][j] * mp[i + 1][j];
				mp[i][j] += 1;
			}
	for (int i = 2; i <= n + 1; i++)
		for (int j = 2; j <= n + 1; j++)
			printf("%lld%c", mp[i][j], (j == n + 1) ? '\n' : ' ');
	return 0;
}


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

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

ll N,A,B,K;
const ll mod = 998244353;

// 以下コピー
const int MAX_FACT = 2000000;
ll fact[MAX_FACT];

ll pow_mod(ll a,ll n){
  ll cur=1;
  ll mul=a;
  while(n){
    if(n%2)cur=(cur*mul)%mod;
    mul=(mul*mul)%mod;
    n/=2;
  }
  return cur;
}

ll div_mod(int a){
  return pow_mod(a,mod-2);
}

// factを前計算
void calcFact(){
  fact[0]=1;
  for(int i=1;i<MAX_FACT;i++)
    fact[i]=(fact[i-1]*i)%mod;
}

// aCbのmodを計算
// 計算量はO(log(fact[a])+log(fact[a-b]))程度
ll comb(ll a,ll b){
  if(a<0||b<0)return 0;
  else if(a<b)return 0;
  else if(b==0)return 1;
  ll res=fact[a];
  res=(res*div_mod(fact[b]))%mod;
  res=(res*div_mod(fact[a-b]))%mod;
  return res;
}

int main(){

    calcFact();
    cin >> N >> A >> B >> K;
    ll ans = 0;
    for(ll i = 0; i * A <= K; i++){
        if((K - i * A) % B == 0){
            ll j = (K - i * A) / B;
            // C(N, i) * C(N, j)
            ans += comb(N, i) * comb(N, j);
            ans %= mod;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 15872
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<iostream>
#include<iterator>
#include<math.h>
#include<cmath>
#include<sstream>
#include<vector>
#include<iomanip>
#include<string>
#include<fstream>
#include<algorithm>
#include<map>
#include<thread>
#include<stack>
#include<numeric>
#include<functional>
#include<queue>
#include<set>
#include<list>
#include<bitset>
#include <cassert>

typedef long long ll;

using namespace std;

const ll MOD = (ll)1000000007;
const ll inf = (ll)1e18;
const long double eps = 0.0000001;

struct th
{
	ll first = -1, second = -1;
	ll third = -1;
};

vector<vector<pair<ll, ll>>> g;
vector<ll> vert;

void dfs(int v, int par)
{
	for (auto &i : g[v])
	{
		if (i.first != par)
		{
			vert[i.first] += vert[v];
			dfs(i.first, v);
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << setprecision(30);

#ifdef _DEBUG
	/*freopen("sorting.in", "r", stdin);
	freopen("sorting.out", "w", stdout);*/

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n, q;
	cin >> n >> q;

	g.resize(n + 1);
	vert.resize(n + 1, 0);

	for (int i = 1; i < n; ++i)
	{
		int u, v;
		cin >> u >> v;

		g[u].push_back({ v, 0 });
		g[v].push_back({ u, 0 });
	}

	while (q--)
	{
		ll x, p;
		cin >> p >> x;

		vert[p] += x;
	}

	dfs(1, 0);

	for (int i = 1; i < n + 1; ++i)
	{
		cout << vert[i] << ' ';
	}

	return 0;
}

Measured memory_bytes: 28416
#include <stdio.h>

int main(void)
{
    int n, p;
    int i, j;
    int ans[210][3] = {0};
    int cnt[3][210] = {0};
    int score[210] = {0};
    scanf("%d", &n);

    for (i = 0; i < n; i++){
        for (j = 0; j < 3; j++){
            scanf("%d", &p);
            ans[i][j] = p;
            cnt[j][p]++;
        }
    }

    for (i = 0; i < n; i++){
        for (j = 0; j < 3; j++){
            if (cnt[j][ans[i][j]] == 1){
                score[i] += ans[i][j];
            }
        }
        printf("%d\n", score[i]);
    }
    return (0);
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<string,int,int>;

int main(){
  int n,k; cin >> n >> k;
  vector<int> s(n);
  for(int i = 0; i < n; i++) s[i] = 0;
  
  for(int i = 0; i < n; i++){
    int d; cin >> d;
    for(int j = 0; j < d; j++){
      int temp; cin >> temp;
      temp--;
      s[temp]++;
    }
  }
  int ans = 0;
  for(int v: s){
    if(v == 0){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
#define fst first
#define snd second
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll n, k; cin >> n >> k;
    vll a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    bool b = true;
    rep(i, k-1, n-1){
        if(a[i-k+1] < a[i+1]){
            prtl("Yes");
        }else{
            prtl("No");
        }
    }
}


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


void solve(long long W, long long H, long long x, long long y){
    cout<<0.5*W*H<<" ";
    if(x*2==W&&y*2==H)cout<<1<<endl;
    else cout<<0<<endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long W;
    scanf("%lld",&W);
    long long H;
    scanf("%lld",&H);
    long long x;
    scanf("%lld",&x);
    long long y;
    scanf("%lld",&y);
    solve(W, H, x, y);
    return 0;
}


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

using namespace std;

int main() {

    string s;
    cin >> s;

    const uint64_t MOD = 2019;
    uint64_t answ = 0;
    uint64_t pow = 1;
    uint64_t num = 0;
    uint64_t d[2020];
    fill(d, d + 2020, 0);
    reverse(s.begin(), s.end());
    d[0] = 1;
    for(const auto& c: s) {
        num = (num + (c - '0') * pow) % MOD;
        answ += d[num]++;
        pow = (pow * 10) % MOD;
    }
    cout << answ;
    return 0;
}

Measured memory_bytes: 3736
S=gets.chomp

c0 = 0
c1 = 0
ret = 0
S.each_char do |c|
    if c == '1'
        if 0 < c0
            ret += 2
            c0 -= 1
        else
            c1 += 1
        end
    else
        if 0 < c1
            ret += 2
            c1 -= 1
        else
            c0 += 1
        end
    end
end
puts ret

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

int N;
#define MAX_N 10000
long long A[MAX_N], B[MAX_N];
long long P, M;

int main() {
  cin >> N;
  for(int i = 0; i < N; ++i) cin >> A[i];
  for(int i = 0; i < N; ++i) cin >> B[i];
  for(int i = 0; i < N; ++i) {
    long long d = B[i] - A[i];
    if(d > 0) P += d / 2;
    else if(d < 0) M += -d;
  }
  cout << (P >= M ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

 int main() {
   ll H, W, ans = INFL; cin >> H >> W;

   ll S1, S2, S3;

   rep(i, 1, H) {
     S1 = W * i;
     S2 = W / 2 * (H - i);
     S3 = (W - W / 2) * (H - i);

     ans = min(ans, max(S1, max(S2, S3)) - min(S1, min(S2, S3)));

     S2 = (H - i) / 2 * W;
     S3 = H * W - S1 - S2;
     ans = min(ans, max(S1, max(S2, S3)) - min(S1, min(S2, S3)));
   }

   rep(i, 1, W) {
     S1 = H * i;
     S2 = H / 2 * (W - i);
     S3 = (H - H / 2) * (W - i);

     ans = min(ans, max(S1, max(S2, S3)) - min(S1, min(S2, S3)));

     S2 = (W - i) / 2 * H;
     S3 = H * W - S1 - S2;
     ans = min(ans, max(S1, max(S2, S3)) - min(S1, min(S2, S3)));
   }

   cout << ans << endl;
 }


Measured memory_bytes: 256
import sys
from heapq import heappush, heappop
from operator import itemgetter

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    res = 0
    camel_left, camel_right = [], []
    for _ in range(N):
        K, L, R = map(int, rl().split())
        res += min(L, R)
        if R <= L:
            camel_left.append([K, L, R])
        elif K != N:
            camel_right.append([N - K, L, R])
    
    camel_left.sort(key=itemgetter(0))
    camel_right.sort(key=itemgetter(0))
    
    hq = []
    i = 0
    for j in range(1, N + 1):
        while i < len(camel_left) and camel_left[i][0] == j:
            heappush(hq, camel_left[i][1] - camel_left[i][2])
            i += 1
        while j < len(hq):
            heappop(hq)
    res += sum(hq)
    
    hq = []
    i = 0
    for j in range(1, N):
        while i < len(camel_right) and camel_right[i][0] == j:
            heappush(hq, camel_right[i][2] - camel_right[i][1])
            i += 1
        while j < len(hq):
            heappop(hq)
    res += sum(hq)
    
    return res


if __name__ == '__main__':
    T = int(rl())
    ans = []
    for _ in range(T):
        ans.append(solve())
    print(*ans, sep='\n')


Measured memory_bytes: 48612
module Main where

main = do
  l1 <- getLine
  let a = read l1
  l2 <- getLine
  let b = read l2
  l3 <- getLine
  let c = read l3
  l4 <- getLine
  let x = read l4

  print (length [(s, t, u)| s <- [0..a], t <- [0..b], u <- [0..c], 500 * s + 100 * t + 50 * u == x])


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
 int H,W;
 cin >> H >> W;
 rep(i,W+2){
 cout << "#";
 }
 cout << endl;
 rep(i,H){
 cout << "#";
 string a;
 cin >> a;
 cout << a;
 
 cout << "#" << endl;
 }
 
 rep(i,W+2){
 cout << "#";
 }
 cout << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
)

func main() {
	scanner.Split(bufio.ScanWords)
	a, b, c, d := scanInt(), scanInt(), scanInt(), scanInt()

	cal := func(n int) int {
		return (n / c) + (n / d) - (n / lcm(c, d))
	}

	ans := b - cal(b)
	ans -= (a - 1) - cal(a-1)

	fmt.Println(ans)
}

func gcd(a, b int) int {

	if a < b {
		a, b = b, a
	}

	for {
		mod := a % b
		if mod == 0 {
			return b
		}
		a, b = b, mod
	}
}

func lcm(a, b int) int {
	return (a / gcd(a, b)) * b
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanText(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func scanTexts(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanText()
	}
	return s
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}


Measured memory_bytes: 640
S = input()

YYMM = False
MMYY = False

a, b = int(S[:2]), int(S[2:4])


if a in range(1, 13):
    MMYY = True
if b in range(1, 13):
    YYMM = True

    
if YYMM and MMYY:
    print("AMBIGUOUS")
elif YYMM and not MMYY:
    print("YYMM")
elif not YYMM and MMYY:
    print("MMYY")
else:
    print("NA")

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

int main() {
  int N,a,b,c;
  cin >> N;
  c = N % 10,a = N / 100,b = (N - 100 * a) / 10;
  if (a == 7 || b == 7 || c == 7) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3644
import bisect
N = int(input())
S = input()
l = [[]for i in range(10)]
lenl = [0]*10
r = [[0]*10 for i in range(N+1)]
for i in range(N-1,-1,-1):
    r[i] = r[i+1][:]
    d = int(S[i])
    r[i][d] = 1
    l[d].append(i)
    lenl[d] += 1
for i in range(10):
    l[i].reverse()
ans = 0

for i in range(10):
    if l[i] == []:
        continue
    a = l[i][0]
    for j in range(10):
        b = bisect.bisect_right(l[j],a)
        if b >= lenl[j]:
            continue
        b = l[j][b]
        ans += sum(r[b+1])

print(ans)


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

int main(){
  string s;
  cin>>s;
  int n=s.size();
  int i=n-1;
  bool p=true;
  while(i>=0){
    if(s[i]=='m'){
      if(i<4){
        p=false;
        break;
      }
      i--;
      if(s[i]!='a'){
        p=false;
        break;
      }
      i--;
      if(s[i]!='e'){
        p=false;
        break;
      }
      i--;
      if(s[i]!='r'){
        p=false;
        break;
      }
      i--;
      if(s[i]!='d'){
        p=false;
        break;
      }
    }
    else if(s[i]=='e'){
      if(i<4){
        p=false;
        break;
      }
      i--;
      if(s[i]!='s'){
        p=false;
        break;
      }
      i--;
      if(s[i]!='a'){
        p=false;
        break;
      }
      i--;
      if(s[i]!='r'){
        p=false;
        break;
      }
      i--;
      if(s[i]!='e'){
        p=false;
        break;
      }
    }
    else if(s[i]=='r'){
      if(i<2){
        p=false;
        break;
      }
      i--;
      if(s[i]!='e'){
        p=false;
        break;
      }
      i--;
      if(s[i]=='m'){
        if(i<4){
          p=false;
          break;
        }
        i--;
        if(s[i]!='a'){
          p=false;
          break;
        }
        i--;
        if(s[i]!='e'){
          p=false;
          break;
        }
        i--;
        if(s[i]!='r'){
          p=false;
          break;
        }
        i--;
        if(s[i]!='d'){
          p=false;
          break;
        }
      }
      if(s[i]=='s'){
        if(i<3){
          p=false;
          break;
        }
        i--;
        if(s[i]!='a'){
          p=false;
          break;
        }
        i--;
        if(s[i]!='r'){
          p=false;
          break;
        }
        i--;
        if(s[i]!='e'){
          p=false;
          break;
        }
      }
    }
    else{
      p=false;
      break;
    }
    i--;
  }
  if(p) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795

ll f(ll a)
{
  ll cnt=0,i;
  if (a==2)return 1;
  for(i=2;i*i<a;i++)
  {
if(a%i==0)cnt+=2;
  }
  if(i*i==a)cnt++;
  return cnt;
}

//vl a(1001);

ll powM(ll a,ll b, ll m)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans%m;
}

ll g(ll a,ll n)
{
  if(a<0)return ((a%n)+n)%n;
  else return a%n;
}
char A[51][51]={0};
char B[51][51]={0};

ll solve(ll x,ll y,ll na,ll ma,ll nb,ll mb)
{
  ll cnt=0;
  for(int i=1;i<=na;i++)
  {
    //ll temp1=x+i;
    if(x+i<=0)continue;
    else if(x+i>nb)break;
    else 
      {
        for(int j=1;j<=ma;j++)
        {
          if(y+j<=0)continue;
          else if(y+j>mb)break;
          else 
            {
              cnt+=A[i][j]=='1'&&B[i+x][j+y]=='1';
            }
        }
      }
  }
  return cnt;
}

int main()
{
ll n;cin>>n;
vl a(n);
for(int i=0;i<n;i++)cin>>a[i];
ll cnt=0,ans=0;
  for(int i=0;i<n-1;i++)
  {
    if(a[i]<a[i+1])
    {
      ans=max(cnt,ans);
      cnt=0;
    }
    else cnt++;
  }
  ans=max(cnt,ans);
cout<<ans<<"\n";


  return 0;

}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func orderN2(values []int) int {
	max := -math.MaxInt32
	diff := 0
	for i := 0; i < len(values); i++ {
		base := values[i]
		for j := i + 1; j < len(values); j++ {
			diff = values[j] - base
			if diff > max {
				max = diff
			}
			// fmt.Println("max", max)
		}
	}
	return max
}

func orderN(values []int) int {
	max := -math.MaxInt32
	min := values[0]
	for j := 1; j < len(values); j++ {
		diff := values[j] - min
		if diff > max {
			max = diff
		}

		if values[j] < min {
			min = values[j]
		}
	}
	return max
}

func main() {
	var readCount int
	fmt.Scan(&readCount)
	values := make([]int, readCount)

	sc := bufio.NewScanner(os.Stdin)
	for i := 0; i < readCount; i++ {
		sc.Scan()
		s := sc.Text()
		values[i], _ = strconv.Atoi(s)
	}

	max := orderN(values)
	// max := orderN2(values)
	fmt.Println(max)
}



Measured memory_bytes: 5448
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main() {
    string S;
    cin >> S;
    char input = S[0];

    map<char, char> m;
    m['A'] = 'T';
    m['T'] = 'A';
    m['C'] = 'G';
    m['G'] = 'C';

    cout << m[input] << endl;
}

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

int main() {
  int N, K, sum = 1;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    if (sum * 2 > sum + K) sum += K;
    else sum *= 2; 
  }
  cout << sum << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <numeric>
#include <ctime>
#include <bitset>
#include <cctype>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/2)
#define PI (2*acos(0.0))
#define EPS (1e-8)

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

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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;

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

int main(void) {
  ios_base::sync_with_stdio(0);
  int _d, n, m, ans;
  while (cin >> _d, _d) {
    cin >> n >> m;
    ans = 0;
    vector<int> d, k(m);
    for (int i = 0; i < n - 1; i++) {
      int tmp; cin >> tmp;
      d.push_back(tmp);
    }
    for (int i = 0; i < m; i++) cin >> k[i];
    d.push_back(0);
    d.push_back(_d);

    sort(d.begin(), d.end());
    
    for (int i = 0; i < m; i++) {
      int target = k[i];
      int l = 0, u = n + 1, mid, min_dist;
      while (l + 1 < u) {
        mid = (l + u) / 2;
        if (target - d[mid] >= 0) l = mid;
        else u = mid;
      }
      min_dist = abs(target - d[l]);
      min_dist = min(min_dist, abs(target - d[l+1]));
      ans += min_dist;
    }
    cout << ans << endl;
  }
  return 0; 
}

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

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

void BITadd(int, int, vector<int> &);
int BITsum(int, const vector<int> &);

// number of inversions (with no BIT and data compression)
// 1-indexed

int main(int argc, char const *argv[])
{
    int n = 0;
    cin >> n;

    // cout << 0 << endl;

    vector<int> veca(n, 0);
    REP(i, n)
    {
        cin >> veca[i];
    }

    vector<int> vecb = veca;
    sort(vecb.begin(), vecb.end());

    map<int, int> mapa;
    REP(i, n)
    {
        mapa.insert(make_pair(vecb[i], i));
    }

    vector<int> b(n, 0);
    vector<int> t(n, 0);

    REP(j, n)
    {
        // b[a[j]] += 1;
        BITadd(mapa[veca[j]], 1, b);
        // cout << "b = {";
        // REP(i, maxa) {
        //     cout << b[i] << ", ";
        // }
        // cout << b[maxa] << "}" << endl;

        // FOR(v, 0, a[j]) {
        //     t[j] += b[v];
        // }
        t[j] = BITsum(mapa[veca[j]], b);
        // cout << "t[" << j << "] = " << t[j] << endl;
    }

    long int res = 0;
    FOR(j, 0, n)
    {
        res += static_cast<long int>((j - t[j]));
    }

    cout << res << endl;

    return 0;
}

void BITadd(int a, int w, vector<int> &b)
{
    for (int x = a; x < static_cast<int>(b.size()); x |= x + 1)
    {
        b[x] += w;
    }
}

int BITsum(int a, const vector<int> &b)
{
    int ret = 0;
    for (int x = a - 1; x >= 0; x = (x & (x + 1)) - 1)
    {
        ret += b[x];
    }
    return ret;
}


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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
// Sat Apr 11 06:23:29 IST 2020   

#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long    
#define MOD                998244353
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"  
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             (x).begin(),(x).end() 

using namespace std ; 
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int M = 1e9+7 ;

int tests(){
  int n ; cin >> n ; 
  int p  = 3  ;
  vector <bool> mark(n+1,false);
  while(p <= n ){
    mark[p] = true ;
    p += 3 ; 
  }
  p = 5 ;
  while( p <= n){
    mark[p] = true ;
    p += 5 ;
  }
  ll ans  = 0 ;
  for(int i = 1 ; i <= n; i++)
    if(!mark[i])
    ans += (ll)i;
  cout << ans  << '\n'; 
  return  0; 
}
int32_t main(){
    I__O ;            
    int cases = 1 ;  
    // cin >> cases ;  
    for(int  _ = 1 ; _ <= cases ; _++ ){   
    // cout << "Case #" << _ << ": "; 
      tests(); 
    }
    return 0 ; 
}

// -Wall -Weptra -O2
// -pedantic -std=c++11
// -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC

Measured memory_bytes: 3740
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int K = sc.nextInt();
    int[] A = new int[M];
    int[] B = new int[M];
    for (int i = 0; i < M; i++) {
      A[i] = sc.nextInt();
      B[i] = sc.nextInt();
    }
    int[] C = new int[K];
    int[] D = new int[K];
    for (int i = 0; i < K; i++) {
      C[i] = sc.nextInt();
      D[i] = sc.nextInt();
    }
    sc.close();


    int[] fc = new int[N + 1];
    Map<Integer, Set<Integer>> g = new HashMap<>();
    for (int i = 0; i < M; i++) {
      Integer a = Integer.valueOf(A[i]);
      Integer b = Integer.valueOf(B[i]);
      if (!g.containsKey(a) && !g.containsKey(b)) {
        Set<Integer> set = new HashSet<>();
        set.add(a);
        set.add(b);
        g.put(a, set);
        g.put(b, set);
      } else if (!g.containsKey(a)) {
        Set<Integer> set = g.get(b);
        set.add(a);
        g.put(a, set);
      } else if (!g.containsKey(b)) {
        Set<Integer> set = g.get(a);
        set.add(b);
        g.put(b, set);
      } else if (g.get(a) != g.get(b)) {
        Set<Integer> setL = g.get(a);
        Set<Integer> setS = g.get(b);
        if (setL.size() < setS.size()) {
          Set<Integer> temp = setL;
          setL = setS;
          setS = temp;
        }
        setL.addAll(setS);
        for (Integer c : setS)
          g.put(c, setL);
      }
      fc[a]++;
      fc[b]++;
    }

    int[] bc = new int[N + 1];
    for (int i = 0; i < K; i++) {
      Integer c = Integer.valueOf(C[i]);
      Integer d = Integer.valueOf(D[i]);
      if (g.get(c) == g.get(d)) {
        bc[c]++;
        bc[d]++;
      }
    }

    int[] ans = new int[N + 1];
    for (int i = 1; i < N + 1; i++)
      if (g.get(i) != null)
        ans[i] = g.get(i).size() - 1 - fc[i] - bc[i];

    for (int i = 1; i < N + 1; i++)
      System.out.print(ans[i] + " ");
    System.out.println();
  }
}

Measured memory_bytes: 157100
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader br =
				new BufferedReader( new InputStreamReader(System.in) );
		int m = Integer.parseInt(br.readLine());

		Node dammy = new Node(0, null, null);
		for (int i=0; i < m; i++) {
			String[] command = br.readLine().split(" ");

			switch (command[0]) {
			case "insert":
				int k = Integer.parseInt(command[1]);
				Node z = new Node(k);
				insert(dammy, z);
				break;
			case "print":
				inorder(dammy.left);
				System.out.println();
				preorder(dammy.left);
				System.out.println();
				break;
			}
		}
	}

	public static class Node {
		int key;

		Node parent;

		Node left;

		Node right;

		public Node(int key) {
			this.key = key;
		}

		public Node(int key, Node left, Node right) {
			this(key);
			this.left = left;
			this.right = right;
		}
	}

//	public static class Tree {
//		Node root;
//
//		Tree left;
//
//		Tree right;
//	}

	public static void preorder(Node u) {
		System.out.print(" " + u.key);

		if (u.left != null) preorder(u.left);

		if (u.right != null) preorder(u.right);
	}

	public static void inorder(Node u) {
		if (u.left != null) inorder(u.left);

		System.out.print(" " + u.key);

		if (u.right != null) inorder(u.right);
	}

	// dammy???left=right???????????????root?????????
	public static void insert(Node dammy, Node z) {
		Node y = null;
		Node x = dammy.left; // root

		while (x != null) {
			y = x;
			if (z.key < x.key)
				x = x.left;
			else
				x = x.right;
		}
		z.parent = y;

		if (y == null)
			dammy.left = dammy.right = z;
		else if (z.key < y.key)
			y.left = z;
		else
			y.right = z;
	}
}

Measured memory_bytes: 149852
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	int n; cin >> n;
	set<string> ss;
	string s1, s2;
	rep(i, 0, n) {
		cin >> s1 >> s2;
		if(s1 == "insert") {
			ss.emplace(s2);
		} else {
			P(ss.find(s2) != ss.end() ? "yes" : "no");
		}
	}
	return 0;
}

Measured memory_bytes: 29688
#include<stdio.h>

int main(){
  long int h, w, nMove;
  scanf("%ld %ld",&h, &w);
  
  if(h==1 || w==1)
    nMove = 1;
  else
    nMove = (h*w+1)/2;
   
  printf("%ld",nMove);
  
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  string S;
  char b[5]={'M','A','R','C','H'};
  long long a[5]={};
  rep(i,N){
    cin >> S;
    rep(j,5) if(S[0]==b[j]) a[j]++;
  }
  int c[10]={0,0,0,0,0,0,1,1,1,2};
  int d[10]={1,1,1,2,2,3,2,2,3,3};
  int e[10]={2,3,4,3,4,4,3,4,4,4};
  long long ans=0;
  rep(i,10) ans+=a[c[i]]*a[d[i]]*a[e[i]];
  cout << ans <<endl;
  return 0;
}


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

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;
static const int INF = (int)1e8;

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

int main(void){
  int W,Q;
  while(cin>>W>>Q,W){
    int hori[101]={};
    REP(i,101)hori[i]=-1;
    while(Q--){
      char c;
      int a,b;
      cin>>c;
      if(c=='s'){
        cin>>a>>b;
        int basyo = INF;
        REP(d,W){
          bool can = true;
          REP(i,b){
            if(d+i>=W||hori[d+i]!=-1) can = false;
          }
          if(can){
            basyo = d;
            break;
          }
        }
        if(basyo!=INF){
          REP(i,b){
            hori[basyo+i] = a;
          }
          cout<<basyo<<endl;
        }else{
          cout<<"impossible"<<endl;
        }
      }else{
        cin>>a;
        REP(i,W){
         if(hori[i]==a)hori[i]=-1;
        }
      }
    }
    cout<<"END"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
A, B, K = map(int, input().split())
L = []
for a in range(A, min(A + K, B + 1)):
    L.append(a)
for b in range(max(B - K + 1, A + 1), B + 1):
    if b not in L:
        L.append(b)
for l in L:
    print(l)


Measured memory_bytes: 3060
// 2011Í[à\I C. ÅZ[g

#include <iostream>

using namespace std;

const int INF = 1000000007;

int main(){
	int n;
	int t[16][17];
	static int dp[1<<16];
	while(cin >> n, n){
		for(int i=0;i<n;i++)
			for(int j=0;j<=n;j++) cin >> t[i][j];
		for(int i=0;i<1<<n;i++) dp[i] = INF;
		dp[0] = 0;
		for(int i=0;i<(1<<n)-1;i++){
			if(dp[i]==INF) continue;
			for(int j=0;j<n;j++){
				if(i&(1<<j)) continue;
				int time = t[j][0];
				for(int k=0;k<n;k++)
					if(i&(1<<k)) time = min(time, t[j][k+1]);
				dp[i|(1<<j)] = min(dp[i|(1<<j)], dp[i]+time);
			}
		}
		cout << dp[(1<<n)-1] << endl;
	}
}

Measured memory_bytes: 0
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

w,h,n = map(int, input().split())

s = []

for i in range(h):
    retsu = []
    for j in range(w):
        retsu.append(0)
    s.append(retsu)

for i in range(n):
    x,y,a = map(int, input().split())
    if (a == 1):
        for i in range(h):
            for j in range(x):
                s[i][j] = 1
    elif a == 2:
        for i in range(h):
            for j in range(x,w):
                s[i][j] = 1
    elif a == 3:
        for i in range(y):
            for j in range(w):
                s[i][j] = 1
    else:
        for i in range(y,h):
            for j in range(w):
                s[i][j] = 1

#print(s)

ans = 0

for i in range(h):
    for j in range(w):
        if s[i][j] == 0:
            ans += 1
print(ans)


Measured memory_bytes: 9316
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)N;i++)
#define p(s) cout<<(s)<<endl
#define ck(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9;

int main() {
	int n,mx=0,mn=inf;
	cin>>n;
	REP(i,0,n){
		int a;
		cin>>a;
		mx=max(mx,a);
		mn=min(mn,a);
	}
	p(mx-mn);
	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    ABC126DEvenRelation solver = new ABC126DEvenRelation();
    solver.solve(1, in, out);
    out.close();
  }

  static class ABC126DEvenRelation {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      PotentialUnionFind puf = new PotentialUnionFind();
      StringBuilder sb = new StringBuilder();
      int n = in.nextInt();
      int[] u = new int[n];
      int[] v = new int[n];
      long[] w = new long[n];
      puf.init(n);
      for (int i = 0; i < n - 1; i++) {
        u[i] = in.nextInt() - 1;
        v[i] = in.nextInt() - 1;
        w[i] = in.nextLong();
        puf.union(u[i], v[i], w[i]);
      }

      for (int i = 0; i < n; i++) {
        sb.append((puf.potential(i) % 2) == 0 ? 0 : 1);
        sb.append("\n");
      }
      out.println(new String(sb));

    }

  }

  static class UnionFind {

    int[] par;
    int[] rank;

  }

  static class PotentialUnionFind extends UnionFind {

    private long[] pot;

    void init(int n) {
      par = new int[n];
      rank = new int[n];
      pot = new long[n];
      for (int i = 0; i < n; i++) {
        par[i] = i; // はじめは全員が根である
        rank[i] = 0;
        pot[i] = 0;
      }
    }

    int root(int x) {
      if (par[x] == x) {
        return x;
      } else {
        int r = root(par[x]);
        pot[x] += pot[par[x]];
        par[x] = r;
        return par[x];
      }
    }

    void union(int x, int y, long w) {
      w = w + potential(x) - potential(y);
      int rx = root(x);
      int ry = root(y);
      if (rx == ry) {
        return;
      }
      if (rank[rx] < rank[ry]) {
        int tmp = rx;
        rx = ry;
        ry = tmp;
        w = -w;
      }
      if (rank[rx] == rank[ry]) {
        rank[rx]++;
      }
      par[ry] = rx;
      pot[ry] = w;
    }

    long potential(int x) {
      root(x);
      return pot[x];
    }

  }
}



Measured memory_bytes: 96616
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


//Dinic

#define NUM 2005


//辺を表す構造体(行先、容量、逆辺のインデックス)
struct Edge{
	Edge(int arg_to,int arg_capacity,int arg_rev_index){
		to = arg_to;
		capacity = arg_capacity;
		rev_index = arg_rev_index;
	}
	int to,capacity,rev_index;
};

int V;
int index_row[NUM],index_col[NUM];

vector<Edge> G[NUM]; //グラフの隣接リスト表現
int dist[NUM]; //sourceからの距離
int cheked_index[NUM]; //どこまで調べ終わったか

//fromからtoへ向かう容量capacityの辺をグラフに追加する
void add_edge(int from,int to,int capacity){
	G[from].push_back(Edge(to,capacity,G[to].size()));
	G[to].push_back(Edge(from,0,G[from].size()-1)); //逆辺の、初期容量は0
}

//sourceからの最短距離をBFSで計算する
void bfs(int source){
	for(int i = 0; i < V; i++)dist[i] = -1;
	queue<int> Q;
	dist[source] = 0;
	Q.push(source);

	while(!Q.empty()){
		int node_id = Q.front();
		Q.pop();
		for(int i = 0; i < G[node_id].size(); i++){
			Edge &e = G[node_id][i];
			if(e.capacity > 0 && dist[e.to] < 0){ //辺の容量が正で、かつエッジの行先に未訪問の場合
				dist[e.to] = dist[node_id]+1;
				Q.push(e.to);
			}
		}
	}
}

//増加パスをDFSで探す
int dfs(int node_id,int sink,int flow){
	if(node_id == sink)return flow; //終点についたらflowをreturn

	for(int &i = cheked_index[node_id]; i < G[node_id].size(); i++){ //node_idから出ているエッジを調査
		Edge &e = G[node_id][i];
		if(e.capacity > 0 && dist[node_id] < dist[e.to]){ //流せる余裕があり、かつsourceからの距離が増加する方法である場合
			int tmp_flow = dfs(e.to,sink,min(flow,e.capacity)); //流せるだけ流す
			if(tmp_flow > 0){ //流せた場合
				e.capacity -= tmp_flow; //流した分、エッジの容量を削減する
				G[e.to][e.rev_index].capacity += tmp_flow; //逆辺の容量を、流した分だけ増加させる
				return tmp_flow;
			}
		}
	}
	return 0;
}


//sourceからsinkへの最大流を求める
int max_flow(int source,int sink){ //source:始点 sink:終点
	int flow = 0,add;
	while(true){ //増加パスが存在する限り、流量を追加し続ける
		bfs(source);
		if(dist[sink] < 0)break; //sourceからsinkへと辿り着く残余グラフがない、つまり増加パスが無くなった場合、break
		for(int i = 0; i < V; i++)cheked_index[i] = 0;
		while((add = dfs(source,sink,BIG_NUM)) > 0){ //増加パスが見つかる間、加算
			flow += add;
		}
	}
	return flow;
}


int main(){

	int num_row,num_col;

	scanf("%d %d",&num_row,&num_col);

	int source = 0,sink = 1;
	int index = 2;
	//採番
	for(int i = 0; i < num_row; i++){

		index_row[i] = index++;
	}
	for(int i = 0; i < num_col; i++){

		index_col[i] = index++;
	}

	int capacity;
	int row_sum = 0,col_sum = 0;

	//行の情報
	for(int i = 0; i < num_row; i++){

		scanf("%d",&capacity);
		add_edge(source,index_row[i],capacity);
		row_sum += capacity;
	}
	//列の情報
	for(int i = 0; i < num_col; i++){

		scanf("%d",&capacity);
		add_edge(index_col[i],sink,capacity);
		col_sum += capacity;
	}

	if(row_sum != col_sum){

		printf("0\n");
		return 0;
	}

	//行と列を1対1に対応づける
	for(int i = 0; i < num_row; i++){
		for(int k = 0; k < num_col; k++){
			add_edge(index_row[i],index_col[k],1);
		}
	}

	V = index;
	//最大流で行と列をマッチング
	if(row_sum == max_flow(source,sink)){

		printf("1\n");

	}else{

		printf("0\n");
	}

	return 0;
}



Measured memory_bytes: 27288
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,n,h[100000],cnt,mx;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&h[i]);
	cnt=0; mx=0;
	for(i=1;i<n;i++)	{
		if(h[i]<=h[i-1])	{
			cnt++;
			mx=max(mx,cnt);
		}
		else cnt=0;
	}
	printf("%d\n",mx);
	return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    work_list = [tuple(map(int, input().split())) for i in range(n)]

    dp = [[0] * 3 for i in range(n)]
    for i, work in enumerate(work_list):
        for i_now in range(3):
            for i_pre in range(3):
                if i_now == i_pre:
                    continue

                if i - 1 >= 0:
                    dp[i][i_now] = max(dp[i][i_now], dp[i - 1][i_pre] + work[i_now])
                else:
                    dp[i][i_now] = work[i_now]

    print(max(dp[-1]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 40256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  map<int, int> m1, m2;
  int N; cin >> N;
  for (int i = 0; i < N; ++i) {
    int a; cin >> a;
    if (i % 2 == 0) m1[a]++;
    else            m2[a]++;
  }

  int total1 = 0, total2 = 0;
  vector<pair<int, int>> p1, p2;
  for (auto [k, v] : m1) {
    p1.push_back({v, k});
    total1 += v;
  }
  for (auto [k, v] : m2) {
    p2.push_back({v, k});
    total2 += v;
  }
  sort(p1.rbegin(), p1.rend());
  sort(p2.rbegin(), p2.rend());

  if (p1[0].second == p2[0].second) {
    int v1 = (total1 - p1[0].first) + (total2 - p2[1].first);
    int v2 = (total1 - p1[1].first) + (total2 - p2[0].first);
    cout << min(v1, v2) << endl;
  } else {
    cout << (total1 - p1[0].first) + (total2 - p2[0].first) << endl;
  }
}


Measured memory_bytes: 8880
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char[] c = s.toCharArray();
    Arrays.sort(c);
    String l = new String(c);
    System.out.println(l.equals("abc") ? "Yes" : "No");
  }
}


Measured memory_bytes: 35760
from copy import deepcopy

h, w, k = map(int, input().split())
c = [[0] * w for _ in range(h)]
for i in range(h):
    for j, x in enumerate(input()):
        c[i][j] = int(x == "#")

ans = 0
n = h+w
for bit in range(2**n):
    cc = deepcopy(c)
    for i in range(n):
        if (bit >> i) & 1:
            x = i
            if x >= h: # 縦
                x -= h
                for j in range(h):
                    cc[j][x] = 0
            else:
                for j in range(w):
                    cc[x][j] = 0
    s = sum(map(sum, cc))
    if s == k: ans += 1

print(ans)



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

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

// nCrの計算
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();


    ll N,K;
    cin >> N >> K;

    for(ll i = 1; i <= K; i++){
      ll ans = COM(N-K+1, i);
      ans %= MOD;

      ans *= COM(K-1, i-1);
      ans %= MOD;
      cout << ans << endl;
    }
}



Measured memory_bytes: 12160
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, k := scanInt(), scanInt()
	a := scanInts(n)

	sort.Slice(a, func(i, j int) bool { return abs(a[i]) > abs(a[j]) })

	ans := 1
	c := 0
	lp, lm := -1, -1
	for i := 0; i < k; i++ {
		if a[i] < 0 {
			lm = i
			c++
		} else {
			lp = i
		}
	}

	if c%2 == 1 {
		p, m := -1, -1
		for i := 0; i < n-k; i++ {
			if a[n-1-i] < 0 {
				if lp != -1 {
					m = n - 1 - i
				}
			} else {
				if lm != -1 {
					p = n - 1 - i
				}
			}
		}

		if p == -1 && m == -1 {
			for i := 0; i < k; i++ {
				ans = ans * a[n-1-i] % mod
			}
			fmt.Fprintln(wr, (ans+mod)%mod)
			return
		}

		if m == -1 {
			a[lm] = a[p]
		} else if p == -1 {
			a[lp] = a[m]
		} else {
			if a[lm]*a[m] < a[lp]*a[p] {
				a[lm] = a[p]
			} else {
				a[lp] = a[m]
			}
		}
	}

	for i := 0; i < k; i++ {
		ans = ans * a[i] % mod
	}
	fmt.Fprintln(wr, (ans+mod)%mod)
}

const mod = 1000000007


Measured memory_bytes: 5892
import sys

N, M, C = map(int, input().split())
B = list(map(int, sys.stdin.readline().rsplit()))
A = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(N)]

res = 0
for a in A:
    cnt = 0
    for i in range(M):
        cnt += a[i] * B[i]
    if cnt + C > 0:
        res += 1

print(res)


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

int main(){
	string s; cin >> s;
	int count = 0;
	if (s[0] == '1') count++;
	if (s[1] == '1') count++;
	if (s[2] == '1') count++;
	cout << count << endl;
}

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

int Binary_Search(int S[],int n,int search_num){
  int right = n-1, left =0;

  while(left <= right){
    int mid = (right + left)/2;
    if(S[mid] == search_num){return 1;}
    else if(S[mid] >search_num){right =mid-1;}
    else if(S[mid] <search_num){left =mid+1;}
  }
  return 0;
}
int main(){
  int array_size,q,t;
  cin >> array_size;
  int S[array_size];
  int answer =0;
  for(int i=0;i<array_size;i++) cin >> S[i];
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> t;
    answer +=Binary_Search(S,array_size,t);
  }
  cout << answer <<"\n";
  return 0;
}

Measured memory_bytes: 3464
import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;

void main()
{
    auto nm = readln.chomp.split.map!(to!long);
    long n = nm[0];
    long m = nm[1];
    auto A = readln.chomp.split.map!(to!long).array;

    long[long] t;
    t[0] = 1;
    long b;

    foreach (a; A)
    {
        b += a;
        b %= m;
        long mod = b % m;
        if (mod in t)
            t[mod]++;
        else
            t[mod] = 1;
    }
    long result;
    foreach (key, val; t)
    {
        result += (val).c(2);
    }
    writeln(result);
}

long c(long a, long b)
{
    if (a < b)
    {
        return 0;
    }

    long c = 1;
    foreach (i; a - b + 1 .. a + 1)
        c *= i;
    long d = 1;
    foreach (i; 1 .. b + 1)
        d *= i;
    return c / d;
}


Measured memory_bytes: 8912
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
# from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,K = map(int, input().split())
    HS = [int(input()) for _ in range(N)]
    HS.sort()

    ans = float('inf')
    for i in range(N-K+1):
        ans = min(ans,HS[i+K-1]-HS[i])
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 8376
#include<iostream>
using namespace std;
int main() {
  int m,d; cin >> m >> d;
  int ans=0;
  for(int i=4;i<=m;i++){
    for(int j=1;j<=d;j++){
      int s,t; s=j/10; t=j%10;
      if(s>=2 && t>=2 && i==s*t) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256