akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader(System.in);
//        InputReader in = new InputReader(new FileInputStream("/Users/KeFA/projects/competitve/src/main/java/input.txt"));
        PrintWriter out = new PrintWriter(System.out);

        while (in.ready()) {
            String s1 = in.next();
            String s2 = in.next();
            if (s1.charAt(0) == s2.charAt(2) && s1.charAt(1) == s2.charAt(1) && s1.charAt(2) == s2.charAt(0)) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
        out.flush();
        out.close();
    }

    private static class InputReader {
        StringTokenizer st;
        BufferedReader br;

        public InputReader(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}


Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();

        long sum = 0;
        final long[] array = new long[n];
        for (int i = 0; i < n; i++) {
            final int a = scanner.nextInt();
            array[i] = a;
            sum += a;
        }

        long min = Long.MAX_VALUE;
        long sum2 = 0;
        for (int i = 0; i < n - 1; i++) {
            final long tmp = array[i];
            sum2 += tmp;
            sum -= tmp;

            min = Math.min(min, Math.abs(sum - sum2));
        }

        System.out.println(min);
    }
}


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

int main() {	
	int a, b;
	char op;
	cin >> a >> op >> b;

	while (op != '?') {
		switch (op) {
			case '+':
				cout << a + b << endl;
				break;
			case '-':
				cout << a - b << endl;
				break;
			case '*':
				cout << a * b << endl;
				break;
			case '/':
				cout << a / b << endl;
				break;
		}
		cin >> a >> op >> b;
	}
	
	return 0;
}


Measured memory_bytes: 3100
import numpy as np

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

list1 =[input() for i in range(h)]
#print(list1)

list2=[]
for i in range(h):
  if list1[i].count('#') > 0:
    list2.append(list1[i])
#print(list2)
list2_num=len(list2)

list4=[]
for i in range(list2_num):
  list3=(list(list2[i]))
  list4.append(list3)
#print(list4)
list4=np.array(list4).T
#print(list4)

list4=list4.tolist()
list5=[]
for i in range(w):
  if list4[i].count('#') > 0:
    list5.append(list4[i])
#print(list5)

list5=np.array(list5).T
#print(list5)
list5=list5.tolist()
#print(list5)
for i in range(len(list5)):
  for j in range(len(list5[0])):
    print(list5[i][j], end='')
  print('')

Measured memory_bytes: 13920
from bisect import bisect_left
from collections import deque

n = int(input())
ans = []
ans.append(int(input()))
ans = deque(ans)
for i in range(n-1):  
  temp = int(input())
  if temp <= ans[0]:
    ans.appendleft(temp)
  else:
    ans[bisect_left(ans, temp)-1]=temp
print(len(ans))
  

Measured memory_bytes: 76684
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,c=0;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	{
	    cin>>a[i];
	    if(a[i]>=k)
	        c++;
	}
	cout<<c<<endl;
}

Measured memory_bytes: 640
A,B,M = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

ans = 10**9
for i in range(M):
    x,y,c = [int(i) for i in input().split()]
    if ans > a[x-1] + b[y-1] - c:
        ans = a[x-1] + b[y-1] - c
if ans > min(a) + min(b):
    ans = min(a) + min(b)
print(ans)

Measured memory_bytes: 66540
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
using namespace std;
#define INF (1<<28)
struct NODE{
	int x,y,c;
	NODE(int x,int y,int c) : x(x) , y(y) , c(c) {}
};

int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};
int w,h;
char field[20][20];
int dist[11][11];

int tsp[11][1<<11];

int bfs(int x,int y,int x2,int y2){
	queue<NODE> Q;
	int done[21][21] = {};
	Q.push(NODE(x,y,0));
	while(Q.size()){
		NODE q = Q.front(); Q.pop();
		if( done[q.y][q.x]++) continue;
		if( x2 == q.x && y2 == q.y ) return q.c;
		for(int i = 0 ; i < 4 ; i++){
			int tx = q.x + dx[i];
			int ty = q.y + dy[i];
			if( tx < 0 || tx >= w || ty < 0 || ty >= h || field[ty][tx] == 'x') continue;
			Q.push(NODE(tx,ty,q.c+1));
		}
	}
	return INF;
}

int main(){
	while(cin >> w >> h && w){
		vector<int> x,y;
		for(int i = 0 ; i < h ; i++){
			for(int j = 0 ; j < w ; j++){
				cin >> field[i][j];
			}
		}
		for(int i = 0 ; i < h ; i++)
			for(int j = 0 ; j < w ; j++)
				if(field[i][j] == 'o') x.push_back(j) , y.push_back(i);
		for(int i = 0 ; i < h ; i++)
			for(int j = 0 ; j < w ; j++)
				if(field[i][j] == '*') x.push_back(j) , y.push_back(i);
		for(int i = 0 ; i < 11 ; i++)
			for(int j = 0 ; j < (1<<11) ; j++)
				tsp[i][j] = INF;
		for(int i = 0 ; i < x.size() ; i++)
			for(int j = 0 ; j < x.size() ; j++)
				dist[i][j] = bfs(x[i],y[i],x[j],y[j]);
		
		tsp[0][1] = 0;
		for(int i = 0 ; i < (1<<x.size()) ; i++){
			for(int j = 0 ; j < x.size() ; j++){
				for(int k  = 0 ; k < x.size() ; k++){
					if(i >> j & 1){
						tsp[k][i|(1<<k)] = min(tsp[j][i]+dist[j][k],tsp[k][i|(1<<k)]);
					}
				}
			}
		}
		int ans = INF;
		for(int i = 0 ; i < x.size() ; i++){
			ans = min(tsp[i][(1<<x.size())-1],ans);
		}
		if( ans >= 1000000) cout << -1 << endl;
		else cout << ans << endl;
	}
}

Measured memory_bytes: 996
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);

    ll n,m;
    cin >> n >> m;

    ll a = 1900*m + 100*(n-m);
    a = a*pow(2,m);
    cout << a;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm> // sort
#include <map>       // pair
#include <vector>
using namespace std;

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


const int INF = 100100100;
const int MOD = (int)1e9 +7;
const double EPS = 1e-9; 

typedef long long int ll;

//char in[120];
//ex. pair
//pair<pair<string,int>,int> p[110];

void make_vec(vector<ll>& vec, ll prev, ll n){
    //入ってきたのがデカかったらやらない
    //cout << prev<< endl;
    ll tmp_a = prev * 10 + 3;
    ll tmp_b = prev * 10 + 5;
    ll tmp_c = prev * 10 + 7;
    if(tmp_a <= n){
        vec.push_back(tmp_a);
        make_vec(vec, tmp_a, n);
    }
    if(tmp_b <= n){
        vec.push_back(tmp_b);
        make_vec(vec, tmp_b, n);
    }
    if(tmp_c<=n){
        vec.push_back(tmp_c);    
        make_vec(vec, tmp_c, n);
    }
}

int main(){
    ll n;cin>>n;
    vector<ll> hoge;
    int ans = 0;
    make_vec(hoge,0,n);
    //cout << hoge.size()<<endl;
    sort(hoge.begin(),hoge.end());
    FOR(hoge.size()){
        string tmp = to_string(hoge[i]);
        //cout<<tmp.find('3') << "  " << tmp<< endl;
        if( tmp.find('3') != std::string::npos && tmp.find('5') != std::string::npos && tmp.find('7') != std::string::npos ){
            //cout << tmp << endl;
            ans++;
        }
    }
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
M = 10**4+1
p = [1]*M; a = [0,0]; prm = 0
p[0],p[1] = 0,0
for i in xrange(2,M):
    if p[i]:
        if p[i-2]: prm = i
        for j in xrange(i*i,M,i):
            p[j] = 0
    a.append(prm)
while 1:
    n = input()
    if n==0: break
    print a[n]-2,a[n]

Measured memory_bytes: 4376
#include<stdio.h>
int main(void){
  int a[1000][100],i,j,n,m,sum[100],k;
  while(1){
    for(i=0;i<100;i++){
      sum[i] = 0;
    }
    k = 0;
    scanf("%d %d",&n,&m);
    if(n==0&&m==0)break;
    for(i=0;i<n;i++){
      for(j=0;j<m;j++){
	scanf("%d",&a[i][j]);
      }
    }
    for(i=0;i<m;i++){
      for(j=0;j<n;j++){
	sum[i] += a[j][i];
      }
    }
    for(i=n;i>=0;i--){
      for(j=0;j<m;j++){
	if(sum[j]==i){
	  printf("%d",j+1);
	  k++;
	  if(k!=m)printf(" ");
	}
      }
    }
    printf("\n");
  }
  return(0);
}

Measured memory_bytes: 2092
#include<iostream>
#include<string>
#include<vector>
using namespace std;
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
int main(){
  string s;
  cin>>s;
  int co[4]={0};
  char kupc[4]={'K','U','P','C'};

  rep(i,4)rep(j,s.size())if(s[j]==kupc[i])co[i]++;

  int mini=co[0];
  rep(i,3)mini=min(mini,co[i+1]);

  cout<<mini<<endl;
}

Measured memory_bytes: 1188
from functools import reduce
import math

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    ans = 1e10
    d = 0
    for i in range(int(math.sqrt(N))+1,0,-1):
        if(N%i == 0):            
           d = max(len(str(i)) , len(str(N//i))) 
           ans = min(d,ans)
    print(ans)
    
if __name__ == '__main__':
    main()


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

int main(){
int n ;
cin >>n;
string s;
cin >> s;
int count = 0;
rep(i,n){
  if(s[i]==s[i+1]){
    count ++;
  }
}
cout << n-count<< endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int ans;
	int y,m,d;
	for(int i=0;i<n;i++){
		ans=1;
		cin>>y>>m>>d;
		for(int j=y;j<=999;j++){
			if(j%3==0){
				for(int k=m;k<=10;k++){
					ans+=20-d;
					d=0;
				}
			}
			else{
				for(int k=m;k<=10;k++){
					if(k%2==1){
						ans+=20-d;
					}
					else{
						ans+=19-d;
					}
					d=0;
				}
			}
			m=1;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#include <assert.h>
#include <stdio.h>
typedef long long int lld;

void table(int prev[], int new[]) {
  for (int i = 0; i <= 9; i++) {
    if (prev == NULL) {
      new[i] = 1;
    } else {
      new[i] = 0;
      for (int j = -1; j <= 1; j++) {
        if (i + j < 0 || i + j > 9) {
          continue;
        }
        new[i] += prev[i + j];
      }
    }
  }
}

int main() {
  int k;
  assert(scanf("%d", &k) == 1);

  int cnt[20][10], last;
  lld tmp = k - 1;
  for (int i = 0; i < 20; i++) {
    table(i > 0 ? cnt[i - 1] : NULL, cnt[i]);
    for (int j = 1; j <= 9; j++) {
      if (tmp >= cnt[i][j]) {
        tmp -= cnt[i][j];
      } else {
        last = j;
        printf("%d", last);
        for (int l = i - 1; l >= 0; l--) {
          for (int m = -1; m <= 1; m++) {
            if (last + m < 0 || last + m > 9) {
              continue;
            }
            if (tmp >= cnt[l][last + m]) {
              tmp -= cnt[l][last + m];
            } else {
              last = last + m;
              printf("%d", last);
              break;
            }
          }
        }
        goto exit;
      }
    }
  }
  exit:
  puts("");
}


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

int main() {
  int64_t a, b, c;
  cin >> a >> b >> c;
  if(a % 2 == 1 && b % 2 == 1 && c % 2 == 1){
    vector<int64_t> v = {a, b, c};
    sort(v.begin(), v.end());
    cout << v[0] * v[1] << endl;
  }
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
import bisect

n = int(input())

a_l = list(map(int, input().split()))

plus_l = [i + a_l[i] for i in range(n)]
minus_l = [i - a_l[i] for i in range(n)]

minus_l = sorted(minus_l)

ans = 0

for i in range(n):
    cur = plus_l[i]
    left = bisect.bisect_left(minus_l, cur)
    right = bisect.bisect_right(minus_l, cur)

    if left >= n or minus_l[left] != cur:
        continue

    ans = ans + right - left

print(ans)


Measured memory_bytes: 35308
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e6+6;
const ll MOD=1e9+7;
const int Seed=1e7+7;
template <class T>
bool sf(T &ret){ //Faster Input
    char c; int sgn; T bit=0.1;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    if(c==' '||c=='\n'){ ret*=sgn; return 1; }
    while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;
    ret*=sgn;
    return 1;
}

int main(){
    ll a,b;
    sf(a);sf(b);
    for(int i=1;i<=3;i++){
        ll t=a*b*i;
        if(t%2==1){
            cout <<"Yes"<<endl;
            return 0;
        }
    }
    cout <<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  int n,m,X,Y;
  cin >> n >> m >> X >> Y;
  int x[n];
  int y[m];
  for(int i = 0; i < n; i++) cin >> x[i];
  for(int i = 0; i < m; i++) cin >> y[i];
  sort(x,x+n);
  sort(y,y+m);
  for(int i = x[n-1] + 1; i <= y[0]; i++){
    if(X < i && i <= Y){
      cout << "No War"  << endl;
      return 0;
    }
  }
  cout << "War" << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
ai = [int(i) for i in input().split()]
q = int(input())
bc = [[int(i) for i in input().split()] for j in range(q)]

kosu = [0]*(10**5+1)
for i in range(n):
    kosu[ai[i]] += 1
    
num = [0]*(10**5+1)
tmp = sum(ai)

for i in range(q):
    tmp += kosu[bc[i][0]] * (bc[i][1]-bc[i][0])
    kosu[bc[i][1]] += kosu[bc[i][0]]
    kosu[bc[i][0]] = 0
    print(tmp)

Measured memory_bytes: 31940
using System;
using System.Collections.Generic;
using System.Linq;

class Solution
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var ave = a.Average();
        var minDiff = Math.Abs(a[0] - ave);
        var nearest = 0;
        for (int i = 1; i < n; i++)
        {
            var diff = Math.Abs(a[i] - ave);
            if(diff < minDiff)
            {
                minDiff = diff;
                nearest = i;
            }
        }
        
        Console.WriteLine(nearest);
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 1000000001
int U,V;
int dist_toU;
struct node{
    vector<int> to;
    int dist;
    bool path_toU;
    node(){
        dist=0;
        path_toU=false;
    }
};
void dfs1(int v, int p, vector<node> &nodes){
    for (int i = 0; i < nodes[v].to.size(); i++){
        int v_to=nodes[v].to[i];
        if(v_to==p)continue;
        nodes[v_to].dist=nodes[v].dist+1;
        if(v_to==U){
            nodes[v_to].path_toU=true;
            dist_toU=nodes[v_to].dist;
        }
        dfs1(v_to, v, nodes);
        if(nodes[v_to].path_toU)nodes[v].path_toU=true;
    }
    for (int i = 0; i < nodes[v].to.size(); i++){
        int v_to=nodes[v].to[i];
        if(v_to==p)continue;
        nodes[v].dist=max(nodes[v].dist,nodes[v_to].dist);
    }
}

int main() {
    int N;
    cin>>N;
    cin>>U>>V;U--;V--;
    vector<node> nodes(N);
    for (int i = 0; i < N-1; i++){
        int A,B;
        cin>>A>>B;A--;B--;
        nodes[A].to.push_back(B);
        nodes[B].to.push_back(A);
    }
    dist_toU=0;
    dfs1(V,-1,nodes);
    int move=dist_toU/2+1;
    int ans=0;
    int v=V,p=-1;
    while(move>0){
        for(int v_to:nodes[v].to){
            if(v_to==p)continue;
            if(nodes[v_to].path_toU){
                p=v;
                v=v_to;
                ans=nodes[v].dist-1;
                break;
            }
        }
        move--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 14496
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define pi pair<int, int>
#define f first
#define s second

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int x, y, z;
	cin >> x >> y >> z;
	
	swap(x, y);
	swap(x, z);
	
	cout << x << " " << y << " " << z << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (){

    int i, j, k, v, N;
    int A[1000]={0};

    scanf("%d",&N);
    for(i=0;i <= N-1; i++){
        scanf("%d",&A[i]);//"%d "のスペースが問題だった
    }
    
    //printf("test1");
    for(i=1; i<=N; i++){
        for(k=0; k<N-1; k++){
            printf("%d ",A[k]);
        }
        printf("%d\n",A[N-1]);
        
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
            //if(j < 0 && A[j] <= v) break;
        }
        A[j+1] = v;
        
    }

return 0;
}


Measured memory_bytes: 2036
import itertools

num = int(input())
num_list_1 = list(map(int,input().split()))
num_list_2 = list(map(int,input().split()))

num_list = list(itertools.permutations(range(1,num+1)))
count = len(num_list)
num_list_copy_1 = []

for i in range(0,num):
  num_list_copy = []
  for j in range(0,count):
    if num_list_1[i] == num_list[j][i]:
      num_list_copy.append(num_list[j])
      
    elif num_list_1[i] > num_list[j][i]:
      num_list_copy_1.append(num_list[j])
  
  num_list = num_list_copy
  count = len(num_list_copy)
  
count_a = len(num_list_copy_1)+1
  
num_list = list(itertools.permutations(range(1,num+1)))
count = len(num_list)
num_list_copy_2 = []

for i in range(0,num):
  num_list_copy = []
  for j in range(0,count):
    if num_list_2[i] == num_list[j][i]:
      num_list_copy.append(num_list[j])
      
    elif num_list_2[i] > num_list[j][i]:
      num_list_copy_2.append(num_list[j])
  
  num_list = num_list_copy
  count = len(num_list_copy)
  
count_b = len(num_list_copy_2)+1

print(abs(count_a - count_b))

Measured memory_bytes: 12264
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>

using namespace std;

int main(){
  long long n, m, ans = 1;
  cin >> n >> m;
  if(n == m){
    for(int i = 1; i <= n;i++){
      ans *= i;
      ans %= 1000000007;
      ans *= i;
      ans %= 1000000007;
    }
    ans *= 2;
    ans %= 1000000007;
  }else if(abs(n-m) == 1){
    for(int i = 1; i <= n;i++){
      ans *= i;
      ans %= 1000000007;
    }
    for(int i = 1; i <= m;i++){
      ans *= i;
      ans %= 1000000007;
    }
  }else{
    ans = 0;
  }
  cout << ans << endl;
  return 0;
} 


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

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

		int h = sc.nextInt();
		int w = sc.nextInt();

		String[][] aka = new String[h][w];
		String[][] ao = new String[h][w];

		ArrayList<Integer> tate = new ArrayList<>();
		ArrayList<Integer> yoko = new ArrayList<>();

		char[][] c = new char[h][];

		for (int i = 0; i < h; i++) {
			c[i] = sc.next().toCharArray();
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (c[i][j] == '#') {
					tate.add(i);
					yoko.add(j);
				}
			}
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (j == 0) {
					aka[i][j] = "#";
					ao[i][j] = ".";
				} else if (j == w - 1) {
					aka[i][j] = ".";
					ao[i][j] = "#";
				} else {
					if (i % 2 == 0) {
						aka[i][j] = "#";
						ao[i][j] = ".";
					} else {
						aka[i][j] = ".";
						ao[i][j] = "#";
					}
				}

			}
		}

		for (int i = 0; i < tate.size(); i++) {
			aka[tate.get(i)][yoko.get(i)] = "#";
			ao[tate.get(i)][yoko.get(i)] = "#";
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				System.out.print(aka[i][j]);
			}
			System.out.println();
		}
		System.out.println();

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				System.out.print(ao[i][j]);
			}
			System.out.println();
		}
	}

}


Measured memory_bytes: 55140
#include<bits/stdc++.h>
using namespace std;
int main (){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int cnt=0;
	bool mark=false;
	int n;
	cin>>n;
	for (int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		if (a==b) cnt++;
		else cnt=0;
		if (cnt>=3) mark=true;
	}
	if (mark) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 3660
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(auto &i:a){cin>>i;}
    vector<ll> dp(n,E);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int t=1;t<=k && i+t<n;t++){
            dp[i+t]=min(dp[i+t],dp[i]+abs(a[i+t]-a[i]));
        }
    }
    cout<<dp[n-1]<<endl;
    
    
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#define debug(x) cout << #x << "==" << x << endl;

using namespace std;

template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }


const int INF = 1e+8;

//??\???
#define MAX_N 50000
#define MAX_M 20
int N;
int M;
int C[MAX_M];

// dp ????????????
// int dp[MAX_N + 1];
// bool checked[MAX_N + 1];


// int least_coins(int s) {

//   if(s < 0) { return INF; }     // checked ??§ out of bounds ??????????????????!!
//   if(s == 0) { return 0; }

//   if(checked[s] == true) { return dp[s]; }
//   checked[s] = true;

//   int mn = INF;
//   for(int i = 0; i < M; i++) {
//     mn = min( mn, least_coins( s - C[i] ) + 1 );
//   }

//   return dp[s] = mn;

// }

int main() {
  ios::sync_with_stdio(false);

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

  // ?????¢????????°
  // cout << least_coins(N) << endl;

  // DP table
  // dp[i] := i????????????????????????????????????????????°
  vector< int > dp(N+1, INF);
  dp[0] = 0;
  for(int i = 0; i <= N; i++) {    
    for(int j = 0; j < M; j++) {
      if( C[j] <= i ) {
        dp[i] = min( dp[i-C[j]] + 1, dp[i] );
      }
    }
  }

  cout << dp[N] << "\n";

  return 0;
}

Measured memory_bytes: 3188
#include <stdio.h>
#include <inttypes.h>

int N;
int64_t W;
int64_t w[128], v[128];

int memo[128][128][334];

int64_t search(int idx, int count, int delta) {
	int64_t answer, candidate;
	int64_t current;
	if (idx >= N) return 0;
	if (memo[idx][count][delta]) return ~memo[idx][count][delta];

	answer = search(idx + 1, count, delta);
	current = w[0] * count + delta;
	if (current + w[idx] <= W) {
		candidate = search(idx + 1, count + 1, delta + (int)(w[idx] - w[0])) + v[idx];
		if (candidate > answer) answer = candidate;
	}
	return ~(memo[idx][count][delta] = ~answer);
}

int main(void) {
	int i;
	if (scanf("%d%" SCNd64, &N, &W) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%" SCNd64 "%" SCNd64, &w[i], &v[i]) != 2) return 1;
		if (w[i] < w[0] || w[0] + 3 < w[i]) {
			puts("invalid input");
			return 2;
		}
	}
	printf("%" PRId64 "\n", search(0, 0, 0));
	return 0;
}


Measured memory_bytes: 16640
Module Program
  Sub Main
    Dim s=GetInts()
    Dim a=s(0),b=s(1),c=s(2)
    Dim ans=a+b+c-Math.Max(a,Math.Max(b,c))
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

Measured memory_bytes: 20304
#include<cstdio>
int main(){
	int a,b,c,d;
	while(~scanf("%d %d %d",&a,&b,&c))
	{
		long long sum1;
		if(a>b&&a>c){
			sum1=b+c;
			if(sum1==a){
				printf("Yes\n");
			}else {
				printf("No\n");
			}
		}else if(b>a&&b>c){
			sum1=a+c;
			if(sum1==b){
				printf("Yes\n");
			}else {
				printf("No\n");
			}
		}else {
			sum1=a+b;
			if(sum1==c){
				printf("Yes\n");
			}else {
				printf("No\n");
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,ans,a[55],b[55];
int main(){
    ios::sync_with_stdio(false);
    cin >> n >> m;
    a[0]=b[0]=1;
    for(int i=1;i<=n;i++)
    	a[i]=a[i-1]*2+3,b[i]=b[i-1]*2+1;
    for(int i=n;i>=0;i--){
    	if(m<=0)break;
    	if(m==a[i]){ans+=b[i];break;}
    	if(m==1)break;
    	if(m<=a[i-1]+1)m--;
    	else ans+=b[i-1]+1,m-=a[i-1]+2;
	}
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		if(k % 2 == 0) System.out.println(k * k / 4);
		else System.out.println(k / 2 * (k + 1) / 2);
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


Measured memory_bytes: 35536
#include<iostream>

using namespace std;
int dx[]={0,0,-1,1};
int dy[]={-1,1,0,0};
int main(){
  int n,m,i,j,k;
  cin >> n >> m;
  char mp[n][m];
  for(i=0;i<n;i++)for(j=0;j<m;j++)cin>>mp[i][j];
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      if(mp[i][j]=='#'){
        bool flag=false;
        for(k=0;k<4;k++){
          if(i+dx[k]<n&&0<=i+dx[k]&&j+dy[k]<m&&0<=j+dy[k]){
            if(mp[i+dx[k]][j+dy[k]]=='#')flag=true;
          }
        }
        if(!flag){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout<< "Yes" << endl;
  return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}


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

    vector<int> v(n);

    REP(i, n){
        int a;
        cin >> a;
        v[a-1] = i;
    }

    int seq = 1, maxs = 1;

    REP(i, n-1){
        if(v[i] < v[i+1]) chmax(maxs, ++seq);
        else seq = 1;
    }

    cout << n - maxs << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

long long int result[101][100001] = {};

int main()
{
	int n, W;
	cin >> n >> W;
	int w[100001], v[100001];
	for(int i = 0; i < n; i++){
		cin >> w[i] >> v[i];
		for(int j = 0; j < 100001; j++){
			result[i][j] = mod;
		}
	}
	result[0][0] = 0;
	result[0][v[0]] = w[0];
	for(int i = 1; i < n; i++){
		for(int j = 0; j < 100001; j++){
			result[i][j] = result[i - 1][j];
			if(j >= v[i]) result[i][j] = min(result[i][j], result[i - 1][j - v[i]] + w[i]);
		}
	}
	for(int i = 100000; i >= 0; i--){
		if(result[n - 1][i] <= W){
			cout << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 78336
//package ABC171;
import java.util.*;
import java.io.*;
class Main {

	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long a[]=new long[n];
		for(int i=0;i<n;i++)
		{
			a[i]=sc.nextLong();
			
		}
		
		long xor=0;
		for(int i=0;i<n;i++)
		{
			xor=xor^a[i];
		}
		
		for(int i=0;i<n;i++)
		{
			if(i<n-1)
			{
				System.out.print((a[i]^xor)+" ");
			}
			else
			{
				System.out.print(a[i]^xor);
			}
		}
		System.out.println();
	}

}


Measured memory_bytes: 63816
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, M = mi()
Q = li2(M)
'''
l = [N]*N
for i in range(M):
    ind = max(0, Q[i][0]-1)
    l[ind] = min(Q[i][1]-1, l[ind])

for i in reversed(range(N-1)):
    l[i] = min(l[i], l[i+1])

cnt = 0
i = 0

while True:
    i = l[i]
    cnt += 1
    if l[i] == N:
        break

print(cnt)
'''

dp = [0]*N
#rel = [[] for _ in range(N)]
rel = [N]*N
for s, t in Q:
    rel[s-1] = min(t-1, rel[s-1])

#dp[0] = 0
for i in range(N-1):
    dp[i+1] = max(dp[i], dp[i+1])
    if rel[i] != N:
        dp[rel[i]] = max(dp[i] + 1, dp[rel[i]])

print(dp[N-1])


Measured memory_bytes: 31784
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,n;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		n--;
		long long int a[n],x,p=0,y,z;
		for(i=0;i<=n;i++){
			scanf("%lld",&x);  p+=x;
		}
		for(i=0;i<n;i++) scanf("%lld",&a[i]);
//for(i=0;i<n;i++) printf("1a[%d]=%d\n",i,a[i]);
		sort(a,a+n,greater<int>());
//for(i=0;i<n;i++) printf("2a[%d]=%d\n",i,a[i]);
		x=p*(n+1);z=0;
		for(i=0;i<n;i++){
			z+=a[i];
			y=(p+z)*(n-i);
//printf("%d=(%d+%d)*%d\n",y,p,z,n-i);
			x=max(x,y);
		}
		printf("%lld\n",x);
	}
	return 0;
}


Measured memory_bytes: 3316
N = int(input())
MAX = 450
A = [[1],[1]] #size = 2
#A = [[1,2],[2,3],[3.1]]
size = 0
for i in range(1,MAX):
  if i*(i+1)//2 == N:
    size = i+1
    break
if size == 0:
  print("No")
  exit()
now = 2
while now < size:
  start = now*(now-1)//2+1
  last = [start+i for i in range(now)]
  for j in range(len(A)):
    A[j].append(last[j])
  A.append(last)
  now += 1
print("Yes")
print(len(A))
#ini = [len(A)-1]
for x in A:
  x.insert(0,len(A)-1)
  print(*x)
  


Measured memory_bytes: 76392
from collections import Counter
import numpy as np

N, K, Q = input().split()
A = np.array([int(input()) for i in range(int(Q))])
T = np.full(int(N), int(K))
T -= int(Q)
#unique, counts = np.unique(A, return_counts=True)
#s =  dict(zip(unique, counts))
s = Counter(A)
for key, value in s.items():
    T[(key-1)] += value
for i in T:
    if i <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 20028
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll A, B;
    cin >> A >> B;
    cout << var_max(A + B, A - B, A * B) << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int m = sc.NextInt();
        int[] a = sc.IntArray();

        long sum = 0;
        foreach (int i in a)
        {
            sum += i;
        }

        int cnt = 0;
        foreach (int i in a)
        {
            // i < sum/4m
            // i * 4m < sum
            if (i * 4 * m >= sum)
            {
                cnt++;
            }
        }

        Console.WriteLine(cnt >= m ? "Yes" : "No");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13396
n=int(input())
a=[0]*n
b=[int(x) for x in input().split()]

a[0]=b[0]
for i in range(n-1):
  a[i]=min(a[i],b[i])
  a[i+1]=b[i]

s=0
for i in range(n):
  s += a[i]

print(s)


Measured memory_bytes: 3060
import java.util.*;

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



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

int n,m;
set<int> s;

void f(int a){
    if(s.erase(a)==0)s.insert(a);
}

int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        f(a);
        f(b);
    }
    if(s.empty()){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	double n,d;
    cin>>n>>d;
    cout<<ceil(n/(d*2+1))<<endl;

//////////////////////////////////////////////////////
return 0;}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0, x = 0;
	REP(i, n)
	{
		if (s[i] == 'I')
			x++;
		else if (s[i] == 'D')
			x--;
		chmax(ans, x);
	}
	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
n,k = map(int, input().split())
d = []
a = []
for _ in range(k):
    d1 = int(input())
    A = list(map(int, input().split()))
    d.append(d1)
    a.append(A)
ans = [0] * n
for s in a:
    for v in s:
        ans[v-1] = 1
print(ans.count(0))    

Measured memory_bytes: 9212
program bounding
  implicit none
  integer :: n, l(100), x, d, m, i
  l = 0
  read(*,*) n, x
  read(*,*) l(1:n)
  d = 0
  m = 0
  do
    m = m+1
    if (m.gt.n) exit
    d = d+l(m)
    if (d.gt.x) exit
  end do
  write(*,'(i0)') m
  stop
end program bounding

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define st first
#define nd second
#define turbo ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vvi vector<vi>
#define qi queue<int>
#define ld long double

using namespace std;

/*---------------------------------------------------------///CODE///---------------------------------------------------------*/

char T[1001][1001];
int dp[1001][1001];
const int MOD = 1e9 + 7;
int main()
{
    turbo

    int H, W; cin >> H >> W;

    dp[1][1] = 1;

    for(int i = 1; i <= H; i++)
        for(int j = 1; j <= W; j++)
        {
            cin >> T[i][j];
            if(T[i][j] == '.')
            {
                if(T[i - 1][j] == '.') dp[i][j] += dp[i - 1][j];
                if(T[i][j - 1] == '.') dp[i][j] += dp[i][j - 1];
                dp[i][j] %= MOD;
            }
        }

    return cout << dp[H][W], 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n,k; cin>>n>>k;
    int ans=0;
    vector<int> x(n);
    for(int i=0; i<n; i++){
        cin>>x.at(i);
        ans+=2*min(abs(x.at(i)),abs(x.at(i)-k));
    }
    cout<<ans<<endl;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

ll solve(int D,int N) {
    switch(D){
        case 0:
            return (N < 100)? N : 101;
        case 1:
            return (N < 100)? 100*N : 10100;
        case 2:
            return (N < 100)? 10000*N : 1010000;
    }
}

int main() {
    int D,N; cin>>D>>N;
    cout << solve(D,N) << endl;
    // cout << (solve(N,a) ? "Yes":"No") << endl;
    return 0;
}


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

int main(){
	/*input*/
	int n;	cin >> n;
	/*calculation*/
	int ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; 4*i+7*j <= n; j++){
			if(n == 4*i+7*j)ans++;
		}
	}
	/*output*/
	if(ans){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256