akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#define ull long long
using namespace std;

const int nmax = 100100;
ull N, C;
vector < pair < ull , ull > > vec;
ull dp[nmax];
ull dp2[nmax];
void read(){
    cin >> N >> C;
    for(int i=0;i < N; ++i){
        ull v,x;
        cin >> x >> v;
        vec.push_back(make_pair(x,v));
    }
}

void solve(){
   // First go clockwise
   sort(vec.begin(), vec.end()); 
   ull cursum2 = 0;
   for(int i = vec.size() - 1; i>=0; --i)
   {
       cursum2+=vec[i].second;
       dp[i] = -(C - vec[i].first) + cursum2;
   }
   cursum2 = 0;
   for(int i =0 ;i < vec.size(); ++i)
   {
        cursum2+=vec[i].second;
        dp2[i] = cursum2 - vec[i].first;
   }
   for(int i = vec.size() - 1; i>=0; --i)
   {
        dp[i] = max(dp[i+1], dp[i]);
   }
   for(int i = 0; i < vec.size(); ++i)
   {
        dp2[i] = max(dp2[(i==0?0:(i-1))], dp2[i]);
   }
   ull ans = max(dp[0], 0LL);
   ull cursum = 0, lastpos=0;
   for(int i = 0; i < vec.size(); ++i)
   {
      cursum += lastpos -vec[i].first + vec[i].second;
      lastpos = vec[i].first;
      ans = max(ans, max(cursum + dp[i+1] -lastpos, cursum));
   }
   
   cursum = 0, lastpos = 0;
   for(int i = vec.size() - 1; i>=0; --i)
   {
//cout << i << ' ' << ans << ' ' << cursum << ' ' << dp2[i-1] << endl;
        cursum += vec[i].second;
        lastpos = C - vec[i].first;
        ans = max(ans,  max(cursum - lastpos, (i == 0? 0 : dp2[i-1]) -2*lastpos + cursum));
   }
   cout << ans << endl;
}

int main(){
    read();
    solve();
}

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

int main(){
    int N, M;
    cin >> N >> M;
    //N:N人
    //M:M種類の食べ物
    vector<int> cnt(M);
    rep(i,N){
        int k;
        cin >> k;
        rep(j,k){
            int a;
            cin >> a;
            a--;
            cnt[a]++;
        }
    }
    int ans = 0;
    rep(i,M){
        if(cnt[i] == N){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
main = do
  s <- getLine
  let [n,x] = map (read::String->Int) . words $ s
  if n /= 0 || x /= 0 then do
      putStrLn . show . sum $ [ max (min n ((x-i+1) `div` 2)-max (i+1) (x-i-n)) 0 | i <- [1.. min (n-1) (x `div` 3) - 1]]
      main
  else
      return ()

Measured memory_bytes: 3964
#include <iostream>
using namespace std;
int main(void){
    int n,m;
    cin >> n>>m;
    
    int A[n][m];
    int b[m][1];
    int result[n][1];
    
    for(int i=0;i<n;i++)
    for(int j=0;j<m;j++){
        A[i][j]=0;
        b[j][0]=0;
        result[i][0]=0;
    }

    for(int i=0;i<n;i++)
    for(int j=0;j<m;j++){
        int v;
        cin >> v;
        A[i][j]=v;
    }

    for(int j=0;j<m;j++){
        int v;
        cin >> v;
        b[j][0]=v;
    }


    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            result[j][0]+=A[j][i]*b[i][0];
        }
    }
    
    for(int j=0;j<n;j++){
        cout << result[j][0] << endl;
    }

}

Measured memory_bytes: 1196
package main

import (
    "fmt"
)

func main() {
    var a, b int
    fmt.Scanf("%d %d", &a, &b)
    s := a + b
    if s % 2 == 0 {
        fmt.Println(s / 2)
    } else {
        fmt.Println("IMPOSSIBLE")
    }
}



Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,ans=0; cin>>n;
    map<ll,ll> m;
    rep(i,n){
        ll a; cin>>a;
        if(m.count(i-a)) ans+=m[i-a];
        if(m.count(i+a)) m[i+a]++;
        else m[i+a]=1;
    }
    cout<<ans<<endl;
}

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

int main(){
    int n;
    int t,x,y;
    int **cdn;
    int dif,dif_t;
    int flag=1;

    scanf("%d",&n);

    cdn=(int**)malloc(sizeof(int*)*n);
    for (int i=0;i<n;i++)
	cdn[i]=(int*)malloc(sizeof(int)*3);

    for (int i=0;i<n;i++){
	scanf("%d %d %d",&t,&x,&y);
	cdn[i][0]=t;
	cdn[i][1]=x;
	cdn[i][2]=y;
    }

    dif=abs(cdn[0][1])+abs(cdn[0][2]);
    dif_t=cdn[0][0];
    if ((dif_t < dif) || ((dif_t-dif)%2 == 1))
	flag=0;

    for (int i=0;i<n-1;i++){
	dif=abs(cdn[i+1][1]-cdn[i][1])+abs(cdn[i+1][2]-cdn[i][2]);
	dif_t=cdn[i+1][0]-cdn[i][0];

	if ((dif_t < dif) || ((dif_t-dif)%2 == 1)){
	    flag=0;
	}
    }

    if (flag) printf("Yes\n");
    else printf("No\n");

    for (int i=0;i<n;i++)
	free(cdn[i]);
    free(cdn);

    return 0;
}

Measured memory_bytes: 4096
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,p = LI()
    print((a*3+p)//2)
    return

#B
def B():
    n = I()
    s = [None for i in range(n)]
    for i in range(n):
        l = input().split()
        s[i] = l+[i]
    s.sort(key = lambda x:(x[0],-int(x[1])))
    for i,a,b in s:
        print(b+1)
    return

#C
def C():
    def dfs(d,k):
        if d == n:
            l.append(k)
        else:
            dfs(d+1,k+[0])
            dfs(d+1,k+[1])
    n,m = LI()
    l = []
    dfs(0,[])
    qu = LIR(m)
    p = LI()
    ans = 0
    for k in l:
        s = 0
        for q in range(m):
            num = qu[q][0]
            lis = list(map(lambda x:x-1, qu[q][1:]))
            su = 0
            for i in lis:
                su ^= k[i]
            if su == p[q]:
                s += 1
        if s == m:
            ans += 1
    print(ans)
    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 46040
#include <vector>
#include <iostream>
using namespace std;
#define MAX 100000
#define INF __INT_MAX__

struct edge{
    int s,t,d;
};

vector<edge> edges;
int d[MAX];

void BellmanFord(int startVertex,int vNum,int eNum){
	fill(d,d + MAX,INF);
	d[startVertex] = 0;
	
	for(int i=0;i < vNum;++i){
		bool update = false;
		for(int j = 0;j < eNum;++j){
			edge e = edges[j];
			if(d[e.s] != INF && d[e.t] > d[e.s] + e.d){
				d[e.t] = d[e.s] + e.d;
				update = true;
			}
		}
		if(!update)break;
	}
	for(int i = 0;i < vNum;++i){
	    for(int j = 0;j < eNum;++j){
	        edge e = edges[j];
			if(d[e.s] != INF && d[e.t] > d[e.s] + e.d){
				cout << "NEGATIVE CYCLE" << endl;
				return;
			}
	    }
	}

	for(int i = 0;i < vNum;++i){
		if(d[i] == INF){
		    cout << "INF"<< endl;
		}
		else cout<< d[i] << endl;
	}
}

int main(){
    int v,e,r;
	cin >> v >> e >> r;
	for(int i = 0;i < e;++i){
		int s,t,d;
		cin >> s >> t >> d;
		edges.push_back({s,t,d});
	}
	BellmanFord(r,v,e);
}


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

int main()
{  
  int n, d;
  cin >> n;
  
  vector<int> a(n+1);
  vector<int> x(n);

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

  for(int i=0; i<n; i++) {
    x[0] += a[i];
    if(i%2 != 0) {
      x[0] -= a[i] * 2;
    }
  }
  
  cout << x[0];
  for (int i=1; i<n; i++) {
    x[i] = a[i-1]*2 - x[i-1];
    cout << " " << x[i];
  }
  
  return 0;
}

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

int main() {
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;

  int n = 5;

  vector<int> time = { a, b, c, d, e };

  int best_time = 1e9;

  do {
    int now_time = 0;
    for (int i = 0; i < n; i++) {
      while(now_time % 10 != 0) {
        now_time++;
      }
      now_time += time[i];
    }
    best_time = min(now_time, best_time);
  } while(next_permutation(time.begin(), time.end()));

  cout << best_time << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String args[]){

    Scanner scan = new Scanner(System.in);

    String str = scan.next();
    int a = Integer.parseInt(str);

    str = scan.next();
    int b = Integer.parseInt(str);
    System.out.println(a*b + " " + 2*(a+b));
  }
}


Measured memory_bytes: 26260
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void f(int x, int y) {
    cout << x << ' ' << y << endl;
}

void solve() {
    int N;
    cin >> N;
    int digits = 0;
    for (; (1 << digits) <= N; digits++);
    if (N == (1 << (digits - 1))) {
        cout << "No" << endl;
        return;
    }

    cout << "Yes" << endl;
    f(1, 2);
    f(1, 3);
    f(2, 3 + N);
    f(3, 2 + N);
    f(2 + N, 1 + N);
    for (int i = 4; i < N; i += 2) {
        int j = i + 1;
        f(1, i);
        f(1, j);
        f(i, j + N);
        f(j, i + N);
    }

    if (N % 2 == 0) {
        int x = 1 << (digits - 1);
        int y = N ^ x ^ 1;
        f(x, N);
        f(y, N + N);
    }
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << a << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long int ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {}

int main(void) {
  int n;cin>>n;
  string s;cin>>s;
  ll r=0;
  ll g=0;
  ll b=0;
  ll ans=0;

  rep(i,0,n-1) {
    if(s[i]=='R') {
      r++;
    }  else if(s[i]=='G') {
      g++;
    } else {
      b++;
    }
  }

  ans=r*g*b;

  ll sub=0;

  rep(i,0,n-1) {
    rep(j,i+1,n-1) {
      if(s[i]==s[j]) continue;
      int k=2*j-i;
      if(s[j]!=s[k]&&s[i]!=s[k]&&k<n) {
        sub++;
      }
    }
 }

  pr(ans-sub);
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}
int main(){
	ll n,m;
	cin>>n>>m;
	cout<<(n-1)*(m-1)<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int main(){
	//~ #ifndef ONLINE_JUDGE
    //~ freopen("file.in", "r", stdin);
	//~ #endif	
	int n,odd=0;
	scanf("%d",&n);
	while(n--){
		int x;
		scanf("%d",&x);
		odd+=x&1;
	}
	if(odd&1)
		puts("NO");
	else
		puts("YES");
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
const int N= 15;
int main()
{
	int a[N]={0};
	for(int i=0;i<10;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=0;i<10;i++)
	{
		for(int j=i;j<10;j++)
		{
			if(a[i]<a[j])
			{
				int tmp =a[i];
				a[i]=a[j];
				a[j]=tmp;
				 
			}
		}
	}
	for(int i=0;i<3;i++)
	{
		printf("%d\n",a[i]); 
	}
	return 0;
}


Measured memory_bytes: 2616
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

class MyClass
{
    public static void Solve()
    {
        var N = int.Parse(Console.ReadLine());
        var adj = new HashSet<int[]>[N];
        for (int i = 0; i < N; i++)
        {
            adj[i] = new HashSet<int[]>();
        }
        for (int i = 0; i < N - 1; i++)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = input[0];
            var B = input[1];
            var w = input[2];
            adj[A].Add(new[] { B, w });
            adj[B].Add(new[] { A, w });
        }
        var que = new Queue<int>();
        var visited = new bool[N];
        var dist = new int[N];
        visited[0] = true;
        que.Enqueue(0);
        while (que.Count > 0)
        {
            var i = que.Dequeue();
            foreach (var arr in adj[i])
            {
                var j = arr[0];
                var w = arr[1];
                if (!visited[j])
                {
                    que.Enqueue(j);
                    visited[j] = true;
                    dist[j] = dist[i] + w;
                }
            }
        }
        var u = 0;
        for (int i = 0; i < N; i++)
        {
            if (dist[u] < dist[i])
            {
                u = i;
            }
        }
        que = new Queue<int>();
        visited = new bool[N];
        visited[u] = true;
        dist = new int[N];
        que.Enqueue(u);
        while (que.Count > 0)
        {
            var i = que.Dequeue();
            foreach (var arr in adj[i])
            {
                var j = arr[0];
                var w = arr[1];
                if (!visited[j])
                {
                    que.Enqueue(j);
                    visited[j] = true;
                    dist[j] = dist[i] + w;
                }
            }
        }
        var v = 0;
        for (int i = 0; i < N; i++)
        {
            if (dist[v] < dist[i])
            {
                v = i;
            }
        }
        Console.WriteLine(dist[v]);
    }

    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}



Measured memory_bytes: 55752
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define dump(x) cerr << #x << "=" << x <<endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);

void solve()
{
	/*--------------------------*/

	int W, H, x, y;
	cin >> W >> H >> x >> y;
	double ans = W * H * 0.5;
	cout << ans << endl;
	if (x * 2 == W && y * 2 == H) cout << 1 << endl;
	else cout << 0 << endl;

	/*--------------------------*/
}

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Contents   : AtCoder Regular Contest 094 d問題 WA
Author     : Kitaura Hiromi
LastUpdate : 20180414
Since      : 20180414
Comment    : 不等式での押さえ込みを意識すること
"""
from math import ceil, sqrt

Q = int(input())
for i in range(Q):
    A, B = sorted(map(int, input().split(" ")))
    s = A*B

    if A == B:
        print(2*A - 2)
    elif A == B + 1:
        print(2*A - 2)
    else:
        C = ceil(sqrt(s)) - 1
        if C*(C+1) >= s:
            print(2*C - 2)
        else:
            print(2*C - 1)

Measured memory_bytes: 3188
N=int(input())
a=list(map(int,input().split(' ')))
b=list(map(int,input().split(' ')))
c=list(map(int,input().split(' ')))

s=sum(b)
for i in range(N-1):
    if(a[i]+1==a[i+1]):
        s+=c[a[i]-1]
print(s)



Measured memory_bytes: 3060
while True:
  N = int(raw_input())

  if N == 0:
    break

  field = [[(0, 0) for x in xrange(N)] for y in xrange(N)]

  for y in xrange(N):
    line = map(int, raw_input().split())

    for x in xrange(N):
      field[y][x] = (line[2 * x + 1], line[2 * x])

  vis = set()

  cnt = 0

  for y in xrange(N):
    for x in xrange(N):

      cur = (y, x)

      if cur in vis: continue

      loop = set()
      loop.add(cur)

      while True:
        cur = field[cur[0]][cur[1]]

        if cur in vis:
          loop.add(cur)
          vis = vis | loop
          break

        if cur in loop:
          loop.add(cur)
          cnt += 1
          vis = vis | loop
          break

        loop.add(cur)
  print cnt

Measured memory_bytes: 7264
'use strict'

const main = (input) => {
    const items = input.split('\n')[1].split(' ')
    const itemSet = new Set(items)
    if(itemSet.size === 4){
        console.log('Four')
    }else{
        console.log('Three')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n;sc(n);
 ans=0;
 ll a[n+10];
 rep(i,0,n){
  sc(a[i]);
  if((i+1)%2==1&&a[i]%2==1)ans++;
 }
 pr(ans);
return 0;}

Measured memory_bytes: 3636
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n,l; cin>>n>>l;
    int teist[n];
    for(int i=0;i<n;i++){
        teist[i]=l+i+1-1;
    }
    int mint=300;
    int mina;
    for(int i=0;i<n;i++){
        if(abs(teist[i])<mint){
            mint=abs(teist[i]);
            mina=i;
        }
    }
    //for(int i=0;i<n;i++) cout<<teist[i]<<endl;
    //cout<<mint<<" "<<mina;
    int ans=0;
    for(int i=0;i<n;i++){
        if(i!=mina) ans+=teist[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <map>
#define _USE_MATH_DEFINES
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 30;
const double EPS = 1e-9;

P road[20000];

int main(){
	int n, m;
	while(cin >> n >> m && (n || m)){
		for(int i = 0; i < n; i++){
			cin >> road[i].second >> road[i].first;
		}
		sort(road, road + n);
		ll res = 0;
		for(int i = n-1; i >= 0; i--){
			P p = road[i];
			int d = road[i].second;
			int cost = road[i].first;
			if(d <= m){
				m -= d;
			}else{
				if(m == 0){
					res += d * cost;
				}else{
					res += (d - m) * cost;
					m = 0;
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Spandan Mishra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CManagement solver = new CManagement();
        solver.solve(1, in, out);
        out.close();
    }

    static class CManagement {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.readInt();
            int[] a = new int[n + 1];

            for (int i = 0; i < n - 1; i++) {
                int num = in.readInt();
                a[num]++;
            }

            StringBuilder sb = new StringBuilder();
            for (int i = 1; i <= n; i++)
                sb.append(a[i] + "\n");

            System.out.println(sb);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 48732
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
    int n; cin >> n;
    int ans=0;
    int min=n+1;
    for(int i=0; i<n; ++i){
        int p; cin >> p;
        if(p<=min){
            ++ans;
            min=p;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
h, w = gets.chomp.split(" ").map(&:to_i)
h_painted, w_painted = gets.chomp.split(" ").map(&:to_i)

painted = h_painted * w + w_painted * h
duplicated = h_painted * w_painted
actual_painted = painted - duplicated
white_remained = h * w - actual_painted

puts white_remained

Measured memory_bytes: 1788
A = input()
A = list(A)
A = list(map(int,A))
B = [0 for _ in range(len(A))]
C = [1 for _ in range(len(A))]
for i in range(len(A)):
    if i%2==0:
        B[i] = 1
        C[i] = 0
count1 = 0
count2 = 0
for i in range(len(A)):
    if A[i]!=B[i]:
        count1 +=1
    if A[i]!= C[i]:
        count2 += 1
print(min(count1,count2))

Measured memory_bytes: 5404
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    string today; 
    cin>>today; 
    
    //vector<string> days { SUN, MON, TUE, WED, THU, FRI, or SAT.}; 
    vector<string> days {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    
    for (int i = 0; i < 7; ++ i) {
        if (days[i] == today) {
            for (int j = 1; j <= 7; ++ j) {
                if (days[ (i+j) % 7 ] == "SUN") {
                    cout <<j<<endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
int solve(int a[],int n,int k){
	int dp[n+1];
  	dp[1]=0;
    for(int i=2;i<=n;i++){
      dp[i]=inf;
      for(int j=i-1;(i-j)<=k&&j>=1;j--){
        int option1=abs(a[i]-a[j])+dp[j];
      	dp[i]=min(option1,dp[i]);
      }
      
    }
    return dp[n];
}
int main(){
	int n,k;
  	cin>>n>>k;
    int a[n+1];
  	for(int i=1;i<=n;i++)cin>>a[i];
  	cout<<solve(a,n,k)<<endl;
	return 0;
}


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

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

    int D[2][N];

    for (int i = 0; i < N; i++)
    {
        cin >> D[0][i] >> D[1][i];
    }

    int count = 0;

    for (int i = 0; i < N - 2; i++)
    {
        if (D[0][i] == D[1][i])
        {
            if (D[0][i + 1] == D[1][i + 1])
            {
                if (D[0][i + 2] == D[1][i + 2])
                {
                    count++;
                }
            }
        }
    }

    if (count == 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3628
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
ans = 0

for i in range(N):
    if B[i] > A[i]:
        if A[i+1] > B[i] - A[i]:
            A[i+1] -= B[i] - A[i]
            ans += B[i]
        else:
            ans += A[i] + A[i+1]
            A[i+1] = 0
        A[i] = 0
    else:
        ans += B[i]
        A[i] -= B[i]

print(ans)


Measured memory_bytes: 19156
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int A,B;
//=============================
void input()
{
    cin>>A>>B;
}
//=============================
//=============================
void solve()
{
    bool ans;
    if (A%2==0 || B%2==0)ans=false;
    else ans=true;

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

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

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

using namespace std;

long long a, b, c;
vector<int> V;

int main()
{
    cin>>a>>b>>c;
    for (int i=1; i<=min(a, b); i++)
        if (a%i==0 && b%i==0)
            V.push_back(i);
    cout<<V[V.size()-c];
    return 0;
}


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

using namespace std;

const int N = 2e5 + 5;

int n, a[N];
map <int, int> mm;
long long ans = 0;

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
        ans += mm[i - a[i]];
        mm[i + a[i]]++;
    }
    
    cout << ans;
    return 0;
}

Measured memory_bytes: 21368
import scala.io.StdIn._
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val H, W, M = in.nextInt
  val rows = new Array[Int](H + 1)
  val cols = new Array[Int](W + 1)

  val ts = Array.fill(M){
    val y = in.nextInt
    val x = in.nextInt
    rows(y) += 1
    cols(x) += 1
    (x, y)
  }

  val rMax = rows.max
  val tRows = rows.count(_ == rMax)
  val cMax = cols.max
  val tCols = cols.count(_ == cMax)
  val targetBomb = ts.count(t => rows(t._2) == rMax && cols(t._1) == cMax) == tRows * tCols
  println(rMax + cMax - (if (targetBomb) 1 else 0))
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int k, x;
    cin >> k >> x;
    if (x <= 500 * k)
        OP("Yes");
    else
        OP("No");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

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

  map<string, int> already;
  for (int i = 0; i < N; ++i)
  {
    string s;
    cin >> s;
    sort(s.begin(), s.end());

    if (already.count(s) == 0)
    {
      already.insert(make_pair(s, 1));
    }
    else if (already.count(s) == 1)
    {
      ++already[s];
    }
  }

  long long count = 0;
  for (auto itr = already.begin(); itr != already.end(); ++itr)
  {
    long long n = itr->second;
    count += n * (n - 1) / 2;
  }
  cout << count << endl;
}

Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int H;
    int W;
    char[][] board;
    
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.H = sc.nextInt();
        this.W = sc.nextInt();
        board = new char[H][W];
        for (int i=0; i<H; i++) {
        	String S = sc.next();
        	for (int j=0; j<W; j++) {
        		board[i][j] = S.charAt(j);
        	}
        }
    }
    
    //解答処理
    private String[][] solve() {
        String[][] answer = new String[H][W];
        int[][] count = new int[H][W];
        
        for (int i=0; i<H; i++) {
        	for (int j=0; j<W; j++) {
        		if (board[i][j] == '#') {
        			count[i][j] = -1;
        			continue;
        		}
        		
        		if (j-1>=0 && board[i][j-1] == '#') {	//左隣
        			count[i][j]++;
        		}
        		if (j+1<W && board[i][j+1] == '#') {	//右隣
        			count[i][j]++;
        		}
        		if (i-1>=0 && board[i-1][j] == '#') {	//上
        			count[i][j]++;
        		}
        		if (i+1<H && board[i+1][j] == '#') {	//下
        			count[i][j]++;
        		}
        		if (i-1>=0 && j+1<W && board[i-1][j+1] == '#') {	//右上
        			count[i][j]++;
        		}
        		if (i+1<H && j+1<W && board[i+1][j+1] == '#') {	//右下
        			count[i][j]++;
        		}
        		if (i-1>=0 && j-1>=0 && board[i-1][j-1] == '#') {	//左上
        			count[i][j]++;
        		}
        		if (i+1<H && j-1>=0 && board[i+1][j-1] == '#') {	//左下
        			count[i][j]++;
        		}
        	}
        }
        
        
        for (int i=0; i<H; i++) {
        	for (int j=0; j<W; j++) {
        		if (count[i][j] == -1) {
        			answer[i][j] = "#";
        		} else {
        			answer[i][j] = String.valueOf(count[i][j]);
        		}
        	}
        }

        return answer;
    }
    
    //出力
    public void show(String[][] answer) {
    	for (int i=0; i<H; i++) {
        	for (int j=0; j<W; j++) {
        		System.out.print(answer[i][j]);
        	}
        	System.out.println(" ");
        }
    }

}


Measured memory_bytes: 36320
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n,a,b;
  cin>>n>>a>>b;

  Int ans=n/(a+b)*a;
  ans+=min(a,n%(a+b));
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int s;
    cin>>s;
    ll c=0;
   while(s>0){
       if(s%10==7)
       {
           c=1;
           break;
       }
       s=s/10;
   }
    if(c==1)
    cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
}

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

using namespace std;

#define MAXN 100

int n;
string words[MAXN+10];

int main()
{
  cin>>n;
  int i, j;
  for(i=0; i<n; i++) cin>>words[i];

  for(i=1; i<n; i++)
  {
    if(words[i-1][words[i-1].size()-1]!=words[i][0])
    {
      cout<<"No";
      return 0;
    }

    for(j=0; j<i; j++) if(words[i]==words[j])
    {
      cout<<"No";
      return 0;
    }
  }

  cout<<"Yes";
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys,collections

N,M = map(int,sys.stdin.readline().split())
ab = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(M)) # multi line with multi param

parents = list(range(N))
def find(x):
  while parents[x] != x:
    x = parents[x]
    parents[x] = parents[parents[x]]
  return x
def union(s,t):
  sp = find(s)
  tp = find(t)
  if sp == tp:
    pass
  elif sp < tp:
    parents[sp] = tp
  else:
    parents[tp] = sp

for a,b in ab:
    union(a-1,b-1)
import collections
d = collections.defaultdict(int)
m = 0
for i in range(N):
    x = find(i)
    d[x] += 1
    m = max(m,d[x])
print(m)


Measured memory_bytes: 44084
#include<stdio.h>
int main(void){
    int n,i,a,j;
    char s;
    int b[10][20];
    scanf("%d",&n);

    for(i=0;i<10;i++){
        for(j=0;j<20;j++){
            b[i][j]=0;
        }
    }

    for(i=0;i<n;i++){
        scanf(" %c %d",&s,&a);
        if(s=='S'){
            b[0][a]=1;
        }
        else if(s=='H'){
            b[1][a]=1;
        }
        else if(s=='C'){
            b[2][a]=1;
        }
        else{
            b[3][a]=1;
        }
    }

    for(i=0;i<4;i++){
        for(j=1;j<=13;j++){
            if(b[i][j]==0){
                if(i==0){
                    printf("S %d\n",j);
                }
                if(i==1){
                    printf("H %d\n",j);
                }
                if(i==2){
                    printf("C %d\n",j);
                }
                if(i==3){
                    printf("D %d\n",j);
                }
            }
        }
    }


    return 0;
 }

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back
#define fi first
#define se second

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;
}
void cmps(vector<int>&v,int &i){
	i=lower_bound(all(v),i)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


signed main(){
	string s;cin>>s;
	int ans=0;
	rep(i,1<<(len(s)-1)){
		int now=s[0]-'0';
		rep(j,len(s)-1){
			if(i>>j&1){
				ans+=now;now=s[j+1]-'0';
			}else now=now*10+(s[j+1]-'0');
		}
		ans+=now;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 256
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    tmp = 100
    for c in [A[i], B[i], C[i]]:
        cnt = 0
        for a in [A[i], B[i], C[i]]:
            if c!=a: cnt+=1
        tmp = min(tmp, cnt)
    ans += tmp
print(ans)

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

template<class T> struct Seg {
    const T ID = INT_MIN; 
    T comb(T a, T b) { return max(a,b); }    
    int n; vector<T> seg;
    Seg(int _n) { n = _n; seg.resize(2*n,0); }
    void pull(int p) { seg[p] = comb(seg[2*p],seg[2*p+1]); }
    void upd(int p, T value) { 
        seg[p += n] = value;
        for (p /= 2; p; p /= 2) pull(p);
    }
    T query(int l, int r) { 
        T ra = ID, rb = ID;
        for (l += n, r += n+1; l < r; l /= 2, r /= 2) {
        if (l&1) ra = comb(ra,seg[l++]);
        if (r&1) rb = comb(seg[--r],rb);
        }
        return comb(ra,rb);
    }
};

int32_t main(){
    int n;cin>>n;
    Seg<int> s(n+1);

    vector<int> h(n);
    for(auto &i : h) cin>>i;
    vector<int> a(n);
    for(auto &i : a) cin>>i;
    map<int,int> mp;
    vector<int> dp(n);
    dp[n-1]=a[n-1];s.upd(h[n-1],dp[n-1]);
    for(int i=n-2;i>=0;i--){
        dp[i]=a[i]+(s.query(h[i]+1,n)==INT_MIN?0:s.query(h[i]+1,n));
        s.upd(h[i],dp[i]);
    }

    // for(int i=0;i<n;i++) cout<<dp[i]<<" ";cout<<"\n";   
    cout<<*max_element(dp.begin(),dp.end());
    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll h,w;
	cin>>h>>w;
	vector<string>a;
	for(ll i=0;i<h;i++){
		string t;
		cin>>t;
		a.push_back(t);
	}
	ll b[2001][2001];
	for(ll i=0;i<h;i++){
		ll now=0;
		for(ll j=0;j<w;j++){
			if(a[i][j]=='.'){
				now++;
				b[i][j]=now;
			}
			else{
				now=0;
				b[i][j]=0;
			}
		}
	}
	for(ll i=0;i<h;i++){
		ll now=b[i][w-1];
		for(ll j=w-2;j>=0;j--){
			if(b[i][j]!=0){
				now=max(now,b[i][j]);
				b[i][j]=now;
			}
			else{
				now=0;
			}
		}
	}
	ll c[2001][2001];
	for(ll i=0;i<w;i++){
		ll now=0;
		for(ll j=0;j<h;j++){
			if(a[j][i]=='.'){
				now++;
				c[j][i]=now;
			}
			else{
				now=0;
				c[j][i]=0;
			}
		}
	}
	for(ll i=0;i<w;i++){
		ll now=c[h-1][i];
		for(ll j=h-2;j>=0;j--){
			if(c[j][i]!=0){
				now=max(now,c[j][i]);
				c[j][i]=now;
			}
			else{
				now=0;
			}
		}
	}
	ll ans=0;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			ans=max(b[i][j]+c[i][j]-1,ans);
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 66944
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] S = sc.nextLine().split(" ");
    List<Integer> list = new ArrayList<>();
    for(int i = 0; i < N; i++){
      list.add(Integer.parseInt(S[i]));
    }
    
    Collections.sort(list);
    
    int ans = 0;
    int count = 0;
    int now = 0;
    for(int i = 0; i < N; i++){
      int n = list.get(i);
      if(now != n){
        if(now < count){
          ans += count-now;
        }else if(now > count){
          ans += count;
        }
        now = n;
        count = 1;
      }else{
        count++;
      }
      
      if(i == N-1 && now != count){
        ans += count > now ? count-now : count;
      }
    }
    System.out.println(ans);
  }
}

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

int main(){
  int h,w;
  cin >> h >> w;
  char c[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> c[i][j];
    }
  }
  int a[h][w*2+1]={},b[h*2+1][w]={};
  int ans[h][w]={},count[h][w]={};
  for(int i=0;i<h;i++){
    int k=0,count=0;
    for(int j=0;j<w;j++){
      if(c[i][j]=='.') count++;
      else{
        a[i][k]=count;
        count=0;
        k+=2;
      }
    }
    a[i][k]=count;
    int s=0;
    int t=a[i][s];
    for(int j=0;j<w;j++){
      while(t==0&&s<w*2){
        s++;
        t=a[i][s];
      }
      if(c[i][j]=='.'){
        ans[i][j]+=a[i][s];
        t--;
      }
    }
  }
  for(int i=0;i<w;i++){
    int k=0,count=0;
    for(int j=0;j<h;j++){
      if(c[j][i]=='.') count++;
      else{
        b[k][i]=count;
        count=0;
        k+=2;
      }
    }
    b[k][i]=count;
    int s=0;
    int t=b[s][i];
    for(int j=0;j<h;j++){
      while(t==0&&s<h*2){
        s++;
        t=b[s][i];
      }
      if(c[j][i]=='.'){
        ans[j][i]+=b[s][i];
        t--;
      }
    }
  }
  int res=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      res=max(res,ans[i][j]);
    }
  }
  cout << max(0,res-1) << endl;
}


Measured memory_bytes: 97920
import java.util.*;
import java.io.*;
public class Main {
  	public static void main(String[] args) {
      	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int max = 0;
      	int total = 0;
      	for(int i = 0; i < n; i++) {
          	int x = sc.nextInt();
          	total += x;
        	max = Math.max(x, max);
        }
      	System.out.println(max < total - max ? "Yes" : "No");
    }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
#include<math.h>
#include<string.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define mod 1000000007
#define INF 0x3f3f3f3f
#define MAX 1000005
using namespace std; 

typedef pair<int, int> pii;

int solve(vector<vector<int>> &v){
    int n = v.size();
    int dp[n+1][3];
    memset(dp,0,sizeof(dp));
    
    for(int i=1;i<=n;i++){
		dp[i][0] = max(dp[i-1][1] + v[i-1][1], dp[i-1][2] + v[i-1][2]);
		dp[i][1] = max(dp[i-1][0] + v[i-1][0], dp[i-1][2] + v[i-1][2]);
		dp[i][2] = max(dp[i-1][1] + v[i-1][1], dp[i-1][0] + v[i-1][0]);
	}
    int ans = INT_MIN;
    ans = max(max(dp[n][0],dp[n][1]), dp[n][2]);
    return ans;
}

int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int n;cin>>n;
    vector<vector<int>> v(n,vector<int>(3));
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){    
            cin >> v[i][j];
        }
    }
    cout<<solve(v)<<endl;        
    return 0;
}



Measured memory_bytes: 9728
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = float('inf')
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    N = NI()
    A = LI()

    # 1000までの素数列
    t = [True] * 1000
    for i in range(2,33):
        j = 2
        while i * j < 1000:
            t[i*j] = False
            j += 1
    p = []
    for i in range(2,1000):
        if t[i]: p.append(i)

    cnt = [0] * 1000000
    for x in A:
        nf = True
        for d in p:
            if d > x: break
            if x % d == 0:
                while x % d == 0:
                    x //= d
                if cnt[d]:
                    nf = False
                    break
                cnt[d] += 1
        else:
            if x > 1:
                if cnt[x]:
                    nf = False
                    break
                cnt[x] += 1
            continue
        if nf: continue
        break
    else:
        print('pairwise coprime')
        return

    g = A[0]
    for x in A[1:]:
        g = math.gcd(g,x)
        if g == 1:
            print('setwise coprime')
            return
    print('not coprime')

if __name__ == '__main__':
    main()

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++) cin >> A.at(i);
  bool OK = true;
  for (int i=0; i<N; i++) {
    if (A.at(i)%2==0) {
      if (A.at(i)%3!=0&&A.at(i)%5!=0) {
        OK = false;
        break;
      }
    }
  }
  if (OK) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
def dec(text,d):
    r=[]
    for i in text:
        c=ord(i)
        if c<65:r.append(i)
        elif c<91:r.append(chr((c-65+d)%26+65))
        else:r.append(chr((c-97+d)%26+97))
    return "".join(r)

while True:
    try:raw=input()
    except:break
    if raw=="":break
    for i in range(26):
        d=dec(raw,i)
        if sum([1 for i in ["the","this","that"] if i in d])>0:break
    print(d)


Measured memory_bytes: 5564
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int vote[30];
char c[105];

int main()
{
	int n;
	while((cin >> n) && (n != 0))
	{
		for (int i = 0; i < n; ++i)
		{
			cin >> c[i]; 
		}

		for (int i = 0; i < 30; ++i)
		{
			vote[i] = 0;
		}

		int top = 27;
		int sec = 27;

		for (int i = 0; i < n; ++i)
		{
			int temp = c[i] - 'A';
			vote[temp]++;
			if (vote[temp] > vote[top])
			{
				sec = top;
				top = temp;
			}
			else if (vote[temp] > vote[sec] && top != temp)
			{
				sec = temp;
			}

			//cout << "top:" << top << "," << vote[temp] << " sec:" << sec << "," << vote[sec] << endl;

			if (vote[top] > vote[sec] + n - i - 1)
			{
				cout << (char)(top + 'A') << " " << i+1 << endl;
				break;
			}

			if(i == n-1)
			{
				cout << "TIE" << endl;
			}
		}
	}
	return 0;
}


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

int main(){
  double a, b, x; cin >> a >> b >> x;
  x /= a;
  //cout << x << endl;
  bool upsidedown = false;
  if(x > a*b/2){
  	upsidedown = true;
  	x = a*b -x;
    //cout << x << endl;
  }
  
  double t1 = b*b/x/2;
  double t2 = 2*x/a/a;
  
  if(upsidedown){
    cout << fixed << setprecision(10);
   cout << atan(t2)*180/3.14159265358 << endl;
  }
  else{
    cout << fixed << setprecision(10);
  	cout << atan(t1)*180/3.14159265358 << endl;
  }
  
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <list>
#include <tuple>
using namespace std;

int main() {
	vector<int> vi;
	int N, X, dummy, ans;
	dummy = scanf("%d %d", &N, &X);
	vi.push_back(X);

	int tmp;
	for (int i = 0; i < N; i++) {
		dummy = scanf("%d", &tmp);
		vi.push_back(tmp);
	}

	sort(vi.begin(), vi.end());

	int size = vi.size();
	for (int i = 0; i < size - 1; i++) {
		vi[i] = vi[i + 1] - vi[i];
	}
	vi.pop_back();

	sort(vi.begin(), vi.end());
	vi.erase(unique(vi.begin(), vi.end()), vi.end());

	for (int i = vi[0]; i > 0; i--) {
		bool NG = false;
		for (auto itr = vi.begin(); itr != vi.end(); itr++) {
			if (*itr % i != 0) {
				NG = true;
				break;
			}
		}
		if (!NG) {
			printf("%d\n", i);
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 892
import java.util.*;


public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      //文字列の長さ
      int n = sc.nextInt();
      //指定する文字の位置
      int k = sc.nextInt();
      sc.nextLine();
      
      //対象文字列
      String str = sc.nextLine();
      
      
      for(int i = 0;i < n;i++){
        if(i == k - 1){
          char c = str.charAt(i);
          String ans = String.valueOf(c);
          System.out.print(ans.toLowerCase());
        }else{
          System.out.print(str.charAt(i));
      }
      }
    }
}


Measured memory_bytes: 35724