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

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a=sc.nextLong();
        long b=sc.nextLong();
        long c=sc.nextLong();
        long left=4*a*b;
        long right= (c-a-b)*(c-a-b);
        if(c-a-b<=0){
            System.out.println("No");
            return;
        }
        if (left < right) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 23380
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        int[] c = new int[n];
        for (int i = 0; i < m * 2; i++) {
            c[in.nextInt() - 1]++;
        }

        for (int i = 0; i < n; i++) {
            out.println(c[i]);
        }

    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if (abs(a-c)<=d) cout<<"Yes";
	else if (abs(a-b)<=d&&abs(b-c)<=d) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

int main() {
    int N;
    double ans = 0, A;
    cin >> N;
    for(int i  = 0; i < N; i++) {
        cin >> A;
        ans += 1 / A;
    }
    ans = 1 / ans;
    cout << setprecision(16) << ans << endl; 
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
char a[3][3];
for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
        cin>>a[i][j];
    }
}
for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
        if(i==j){
            cout<<a[i][j];
        }
    }
}
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#define N 3005
#define x first
#define y second 
using namespace std;
int n,T; 
pair<int,int> a[N];
long long res=0,dp[N][N*2];
bool cmp(pair<int,int> u,pair<int,int> v){
	return u.x<v.x;
}
int main(){
	cin>>n>>T;
	for (int i=1;i<=n;i++)
		cin>>a[i].x>>a[i].y;
	sort(a+1,a+n+1,cmp);
	memset(dp,0,sizeof(dp));
	for (int i=1;i<=n;i++)
		for (int j=0;j<T+a[i].x;j++)
			if (j>=a[i].x)
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i].x]+a[i].y);
			else dp[i][j]=dp[i-1][j];
	res=0;
	for (int i=1;i<=n;i++)
		res=max(res,dp[n][T-1+a[i].x]);
	cout<<res;
	return 0;
}

Measured memory_bytes: 141312
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    char a;
    cin >> a;
    int num = int(a);
    if(65 <= num  && num <= 90){
        cout << "A" << endl;
    }
    else{
        cout << "a" << endl;
    }
    return 0;
}

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

#define all(x) x.begin(),x.end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long MOD=1e9+7;
const long long LINF=1e18;
const int INF=0x3f3f3f3f;
const int MAXN=1000050;

vector<ll>prime;
int vis[MAXN];
ll num[MAXN],div_prime[MAXN];
void get_prime(int n){
    for(ll i=2;i<=n;i++){
        if(!vis[i]){
            prime.push_back(i);
            div_prime[i]=1;
            num[i]=2;
        }
        for(ll p:prime){
            if(i*p>n)break;
            vis[i*p]=1;
            if(i%p==0){
                num[i*p]=num[i]/(div_prime[i]+1)*(div_prime[i]+2);
                div_prime[i*p]=div_prime[i]+1;
                break;
            }else{
                num[i*p]=num[i]*num[p];
                div_prime[i*p]=1;
            }
        }
    }
}
void solve(int T){
	int n;
	scanf("%d",&n);
	get_prime(n);
	ll ans=1;
	for(int i=2;i<n;i++){
		ans+=num[i];
	}
	printf("%lld",ans);
}
signed main(){
	int t=1;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	//scanf("%d",&t); 
	for(int i=1;i<=t;i++){
		solve(i);
	}
}

Measured memory_bytes: 23840
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int k;

  cin >> k;
  vector<bool> visited(k);
  deque<pair<int, int>> d;
  d.push_front(mp(1, 1));
  while(true){
    auto p = d.front();
    d.pop_front();
    int x = p.first, c = p.second;
    if (visited[x])continue;
    visited[x] = true;
    if (x == 0) {
      cout << c << endl;
      return;
    }
    d.push_front(mp(x * 10 % k, c));
    d.push_back(mp((x + 1) % k, c + 1));
  }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 1920
import string

S = input()
reversedS = ''.join(list(S)[::-1])
alphabets = list(string.ascii_lowercase)
lastWord = ''.join(alphabets[::-1])
cnt = [S.count(chr(ord('a')+i)) for i in range(26)]
if len(S) == 26:
    if S == lastWord: print(-1)
    else:
        found = False
        for i in range(len(reversedS)):
            s = reversedS[i]
            largeS = alphabets[ord(s)-ord('a')+1:]
            tailS = list(S)[26-i-1:]
            for lS in largeS:
                if lS in tailS:
                    print(S[:26-i-1]+lS)
                    found = True
                    break
            if found: break
else:
    for j in range(26):
        if cnt[j] == 0:
            S += chr(ord('a')+j)
            print(S)
            break


Measured memory_bytes: 3892
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc112_a
{
    class Program
    {
        public static string Year(int N)
        {
            if (N == 1) return "Hello World";
            else if (N == 2)
            {
                int A = int.Parse(Console.ReadLine());
                int B = int.Parse(Console.ReadLine());
                string Sum = Convert.ToString(A + B);
                return Sum;
            }
            else return "Not Found";
        }

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            Console.WriteLine(Year(N));
        }
    }
}


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

int main(){
  int K,A,B;
  cin >> K >> A >> B;
  int flag = 0;
  for(int i = A; i <= B; i++){
    if(i % K == 0)
      flag = 1;
  }
  if(flag)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  return __gcd(a,b);
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N, K;
  cin >> N >> K;
  
  N--;
  K--;
  
  cout << (int)ceil((double)N/(double)K) << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[]
b=[]
for i in range(n):
    p,q=map(int,input().split())
    a.append((p,i,0))
    a.append((q,i,1))
a.sort(key=lambda x:x[0])
result=0
l=[0]*n
flag=0
for i in range(n):
    if l[a[i][1]]==1:
        flag=1
        break
    else:
        l[a[i][1]]=1
t=a[0][2]
s=0
for i in range(n):
    s+=a[i][2]-a[0][2]
if s==0:
    flag=1
if flag==1:

    for i in range(n):
        result+=a[i][0]
    print(result)
else:
    if a[n-1][1]==a[n][1]:
        for i in range(n):
            result+=a[i][0]
        result+=min(a[n+1][0]-a[n-1][0],a[n][0]-a[n-2][0])
        print(result)
    else:
        for i in range(n):
            result+=a[i][0]
        result+=a[n][0]-a[n-1][0]
        print(result)

Measured memory_bytes: 31736
import itertools
n = int(input())
li= [list(map(int, input().split())) for i in range(n)]

def dis(li_i, li_y):
    return ((li_i[0]-li_y[0])**2+(li_i[1]-li_y[1])**2)**(1/2)

ans=[]
for p in itertools.permutations([i for i in range(n)]):
    total_dis=0
    for v in range(n-1):
        total_dis+=dis(li[p[v]], li[p[v+1]])
    ans.append(total_dis)
print(sum(ans)/len(ans))


Measured memory_bytes: 43500
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> A(n+1,0);
  for(int i=0;i<m;i++){
    int a;
    cin >> a ;
    A.at(a) = 1;
  }
  int cnt1 = 0,cnt2 = 0;
  for(int i=0;i<x;i++){
    cnt1 += A.at(i);
  }
  for(int i=x;i<n+1;i++){
    cnt2 += A.at(i);
  }
  cout << min(cnt1,cnt2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;

int f(int n){
    if(n%2 == 0) return n/2;
    else return 3*n + 1;
}

int main(){
    int s;
    cin >> s;
    vector<int> a(1000001, -1);

    int a_i = s;
    a[a_i] = 1;
    for(int i=2; i<=1000000; i++){
        a_i = f(a_i);
        if(a[a_i] == 1){
            cout << i << endl;
            return 0;
        }
        else{
            a[a_i] = 1;
        }
    }

    return 0;
}

Measured memory_bytes: 4096
import java.io.PrintWriter;
import java.util.*;
public class Main{
	
	public static void main(String[]args) {
		PrintWriter out = new PrintWriter(System.out);
		Scanner sc=new Scanner (System.in);
		int n=sc.nextInt();
		long d=sc.nextLong();
		int c=0;
		for(int i=0;i<n;i++) {
			long a=sc.nextLong();
			long b=sc.nextLong();
			if((a*a+b*b)<=d*d)c++;
		}
		out.println(c);
		out.close();
	}
}

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

using namespace std;

typedef long long ll;
const ll mod = 1e9+7;

template<typename T> ostream& operator << (ostream& os, vector<T> v) {
  for (auto& i : v) os << i << " "; return os; 
}
template<typename T> istream& operator >> (istream& is, vector<T>& v) {
  for (auto& i : v) is >> i; return is;
}
template<typename K, typename V> ostream& operator << (ostream& os, unordered_map<K, V> m) {
  for (auto& i : m) os << i.first << ":" << i.second << endl; return os;
}
template<typename T> inline bool chmin(T& x, T y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template<typename T> inline bool chmax(T& x, T y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

int main() {
  int d, g;
  cin >> d >> g;
  vector<pair<int, int>> v(d);
  for (int i=0; i<d; i++) {
    cin >> v[i].first >> v[i].second;
  }
  int res = INT_MAX;
  for (int mask=0; mask<(1<<d); mask++) {
    int s = 0, num = 0, rest_max = -1;
    for (int i=0; i<d; i++) {
      if (mask >> i & 1) {
        s += 100 * (i+1) * v[i].first + v[i].second;
        num += v[i].first;
      } else {
        rest_max = i;
      }
    }
    if (s < g) {
      int s1 = 100 * (rest_max + 1);
      int need = (g - s + s1 - 1) / s1;
      if (need >= v[rest_max].first) {
        continue;
      }
      num += need;
    }
    res = min(res, num);
  }
  cout << res << endl;
  return 0;
}


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

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

using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(n);
    
    int cnt = 0;
    int last_idx = 0;
    char crnt = 'R';
    
    rep(i, n) {
        if (crnt == 'R') {
            if (s.at(i) == 'R') {
                cnt++;
            } else {
                ans[i - 1] = (cnt + 1) / 2;
                ans[i] = cnt / 2;
                last_idx = i;
                cnt = 1;
                crnt = 'L';
            }
        } else {
            if (s.at(i) == 'L') {
                cnt++;
            } else {
                ans[last_idx - 1] += cnt / 2;
                ans[last_idx] += (cnt + 1) / 2;
                cnt = 1;
                crnt = 'R';
            }
        }
    }
    
    ans[last_idx - 1] += cnt / 2;
    ans[last_idx] += (cnt + 1) / 2;
    
    rep(i, n - 1) {
        cout << ans[i] << " ";
    }
    cout << ans[n-1] << endl;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.buffer.readline

import math

n = int(input())
mod = 1000000007
AB = []
for i in range(n):
    a, b = map(int, input().split())
    AB.append((a, b))

def power(a, n, mod):
  bi=str(format(n,"b")) #2進数
  res=1
  for i in range(len(bi)):
    res=(res*res) %mod
    if bi[i]=="1":
      res=(res*a) %mod
  return res

def toid(a, b):
    flag = False
    if a == 0 and b == 0:
        return (0, 0)
    elif a == 0:
        return (0, 1)
    elif b == 0:
        return (1, 0)
    else:
        if a > 0 and b > 0:
            g = math.gcd(a, b)
            a //= g
            b //= g
        elif a > 0 and b < 0:
            b = -b
            g = math.gcd(a, b)
            a //= g
            b //= g
            b = -b
        elif a < 0 and b > 0:
            a = -a
            g = math.gcd(a, b)
            a //= g
            b //= g
            b = -b
        else:
            a = -a
            b = -b
            g = math.gcd(a, b)
            a //= g
            b //= g
        return (a, b)

def totg(a, b):
    if a == 0 and b == 0:
        return (0, 0)
    elif a == 0:
        return (1, 0)
    elif b == 0:
        return (0, 1)
    else:
        if a > 0 and b > 0:
            g = math.gcd(a, b)
            a //= g
            b //= g
            t = (b, -a)
        elif a > 0 and b < 0:
            b = -b
            g = math.gcd(a, b)
            a //= g
            b //= g
            b = -b
            t = (-b, a)
        elif a < 0 and b > 0:
            a = -a
            g = math.gcd(a, b)
            a //= g
            b //= g
            a = -a
            t = (b, -a)
        else:
            a = -a
            b = -b
            g = math.gcd(a, b)
            a //= g
            b //= g
            a = -a
            b = -b
            t = (-b, a)
        return t


d = {}
ans = 0
for i in range(n):
    a, b = AB[i]
    s = toid(a, b)
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1

ans = 1
used = set()
for k1, v1 in d.items():
    if k1 in used:
        continue
    if k1 == (0, 0):
        continue
    a, b = k1
    k2 = totg(a, b)
    if k2 in d:
        v2 = d[k2]
    else:
        v2 = 0
    temp = power(2, v1, mod)-1+power(2, v2, mod)-1+1
    ans *= temp
    ans %= mod
    used.add(k1)
    used.add(k2)

ans -= 1
if (0, 0) in d:
    ans += d[(0, 0)]

print(ans%mod)

Measured memory_bytes: 122592
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>

using namespace std;

int main(){
  int N,K;
  vector<int> d;
  vector<vector<int > > A;
  cin>>N>>K;
  int d_;

  for(int i=0;i<K;i++){
    cin>>d_;
    d.push_back(d_);
    vector<int> A_;
    int tmp;
    for(int j=0;j<d[i];j++){
      cin>>tmp;
      A_.push_back(tmp);
    }
    A.push_back(A_);
  }
  vector<bool> sunuke;
  for(int i=0;i<N;i++)sunuke.push_back(false);

  for(int i=0;i<K;i++){
    for(int j=0;j<A[i].size();j++){
      sunuke[A[i][j]-1]=true;
    }
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(!sunuke[i]){
      ans++;
    }
  }
  cout<<ans;
}

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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> ac(n),wa(n);
	rep(i,m){
		int p;
		string s;
		cin >> p >> s;
		p--;
		if(ac[p]) continue;
		if(s == "AC") ac[p] = 1;
		else{
			wa[p]++;
		}
	}
	int acwa =0;
	int wawa = 0;
	rep(i,n){
		if(ac[i] == 1) acwa++;
		if(ac[i]) wawa += wa[i];
	}
	cout << acwa << " " << wawa << endl;
}

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

using namespace std;

int main() {
	string s;
	cin >> s;
	int flag = 0;
	int flag2 = 0;
	if (((s[0] - '0') * 10 + s[1] - '0') > 0 && ((s[0] - '0') * 10 + s[1] - '0') <=12)
		flag = 1;
	if (((s[2] - '0') * 10 + s[3] - '0') > 0 && ((s[2] - '0') * 10 + s[3] - '0') <=12)
		flag2 = 1;
	if (flag && flag2)
		cout << "AMBIGUOUS";
	else if (flag == 1) cout << "MMYY";
	else if (flag2 == 1) cout << "YYMM";
	else cout << "NA";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1000001
using namespace std;
inline int read()
{
	int number_read=0,if_ok_read=1;
	char ch_read=getchar();
	while(ch_read<'0'||ch_read>'9')
	{
		if(ch_read=='-')
			if_ok_read=-1;
		ch_read=getchar();
	}
	while(ch_read>='0'&&ch_read<='9')
	{
		number_read=number_read*10+ch_read-'0';
		ch_read=getchar();
	}
	return number_read*if_ok_read;
}
inline void write(int x_write)
{
    if(x_write<0)
	{
    	putchar('-');
		x_write=-x_write;
	}
    if(x_write>9)
		write(x_write/10);
    putchar(x_write%10+'0');
    return ;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n=read(),ans=0,maxn=0;
	for(int i=0;i<n;i++)
	{
		char ch=getchar();
		if(ch=='I')
			ans++;
		else
			ans--;
		maxn=max(maxn,ans);
	}
	write(maxn);
	putchar('\n');
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    string ans = "No";
    if(A == B && A != C) ans = "Yes";
    if(A == C && A != B) ans = "Yes";
    if(B == C && A != B) ans = "Yes";
    cout << ans << endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ld a, b;
    cin >> a >> b;
    b *= 1000;
    cout << (ll)(a * b / 1000) << endl;
    
    return 0;
}



Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll d[MAXn];
ii bc[MAXn];
int main(){
    IOS();
    ll n,m;
    cin >> n >> m;
    REP (i,n) cin >> d[i];
    REP (i,m) cin >> bc[i].Y >> bc[i].X;
    sort(d,d+n);
    sort(bc,bc+m,greater<ii>());

    ll idx = 0;
    REP (i,m) {
        if (idx >= n) break;
        while (bc[i].Y) {
            if (idx >= n) break;
            if (bc[i].X > d[idx]) {
                d[idx] = bc[i].X;
                bc[i].Y--, idx++;
            }
            else break;
        }
    }

    pary(d,d+n);
    ll ans = 0;
    REP (i,n) ans += d[i];
    cout << ans << endl;
}


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

typedef long long llint;

int N, M, Q;
int pq[510][510];

int main() {
    cin >> N >> M >> Q;
    for (int p = 0; p <= N; p++) {
        for (int q = 0; q <= N; q++) {
            pq[p][q] = 0;
        }
    }

    while (M--) {
        int l, r;
        cin >> l >> r;
        for (int p = 1; p <= l; p++) {
            pq[p][r]++;
        }
    }
    for (int p = 1; p <= N; p++) {
        for (int q = p; q <= N; q++) {
            pq[p][q] += pq[p][q - 1];
        }
    }

    while (Q--) {
        int p, q;
        cin >> p >> q;
        cout << pq[p][q] << endl;
    }

    return 0;
}

Measured memory_bytes: 1920
//g++ -std=c++11 -Wall -O2 -o main.exe main.cpp
//g++ -std=c++14 -Wall -O2 -o main.exe main.cpp

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <tuple>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>

using namespace std;

//#define spc " "
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p_ii;
typedef tuple<int, int, int, int> tup;

ll divc(ll a, ll b){ //割り算(切り上げ)
    return (a + b - 1) / b;
}

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

int main(){
    string s;
    cin >> s;

    for(int i = 0; i < (int)(s.length()); i++){
        if(s[i]=='?'){
            if(i!=0 && s[i+1]=='D' && s[i-1]!='P') cout << 'P';
            else cout << 'D';
        }
        else cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3756
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String a= sc.next();
        char[] b= a.toCharArray();
        if(b[0]>='a'&&b[0]<'z')
            b[0]++;
        char ch = (char)(b[0]);
        System.out.println(ch);
    }}

Measured memory_bytes: 21844
n,m = gets.split.map(&:to_i)
a,b = m.times.map{gets.split.map(&:to_i)}.transpose

pt = Array.new(n+1).map{Array.new(0)}
for i in 0..(m-1)
  pt[a[i]].push(b[i])
  pt[b[i]].push(a[i])
end

vis = Array.new(n+1,0)
ans = Array.new(n+1,0)
ids = Array.new(1,1)

nxt = Array.new(0)
for i in 0..(n-1)
  id = ids[i]
  vis[id] = 1
  pt[id].each do |nx|
    if vis[nx] == 0
      vis[nx] = 1
      ans[nx] = id
      ids.push(nx)
    end
  end
end

puts "Yes"
for i in 2..n
  puts ans[i]
end

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

using namespace std;

#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;

string f(ll a,ll b,ll c,ll d, ll maxRow){
    c = max(c,0ll);
    d = min(d,a+b);
    if(d<=c) return "";
    //cout<<a<<"f"<<b<<endl;
    assert(a>=0&&b>=0);
    if(b==0){
        return string(d-c,'A');
    }
    if(a==0){
        return string(d-c,'B');
    }
    bool sw = false;
    if(b>a){
        swap(a,b);
        sw = true;
        c = a+b-c;
        d = a+b-d;
        swap(c,d);
        sw = true;
    }
    if(maxRow==-1)
        maxRow = a/(b+1)+(a%(b+1)!=0);
    //cout<<a<<" "<<b<<" "<<maxRow<<endl;
    ll aNeeded = 0;
    ll bNeeded = 0;
    rep(x,0,100){
        bNeeded = (a-aNeeded)/maxRow +((a-aNeeded)%maxRow!=0) - 1;
        bNeeded = max(0ll,bNeeded);
        ll newANeeded = (b-bNeeded)/maxRow +((b-bNeeded)%maxRow!=0)-1;
        newANeeded = max(0ll,newANeeded);
        //cout<<newANeeded<<" "<<bNeeded<<endl;
        if(newANeeded==aNeeded) break;
        aNeeded = newANeeded;
    }
    string ans = "";
    ll fir = a-aNeeded+bNeeded;
    string sec = f(aNeeded,b-bNeeded,c-fir,d-fir,maxRow);
    rep(i,c,min(d,fir)) {
        if((i+1)%(maxRow+1)==0) ans+="B";
        else ans += "A";
    }
    ans += sec;
    if(sw){
        rep(i,0,ans.size()){
            if(ans[i]=='A') ans[i]='B';
            else ans[i] = 'A';
        }
        reverse(all(ans));
    }
    return ans;
}

int main(){
	cin.sync_with_stdio(false);
	ll q; cin>>q;
	while(q--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        string ans = f(a,b,c-1,d,-1);
        cout<<ans<<endl;
        //rep(i,c-1,d) cout<<ans[i];
        //cout<<endl;
	}
}


Measured memory_bytes: 384
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Edge = Tuple!(int, "u", int, "v");

void main() {
    int n, k;
    scan(n, k);
    auto es = new Edge[](n - 1);
    auto adj = new int[][](n, 0);
    foreach (i ; 0 .. n - 1) {
        int u, v;
        scan(u, v);
        u--, v--;
        adj[u] ~= v;
        adj[v] ~= u;
        es[i] = Edge(u, v);
    }

    int dfs(int v, int p, int dep, int lim) {
        int res = dep > lim;

        foreach (u ; adj[v]) if (u != p) {
            res += dfs(u, v, dep + 1, lim);
        }

        return res;
    }

    int ans = n;

    if (k & 1) {
        foreach (e ; es) {
            int u = e.u;
            int v = e.v;

            ans = min(ans, dfs(u, v, 0, k / 2) + dfs(v, u, 0, k / 2));
        }
    }
    else {
        foreach (v ; 0 .. n) {
            ans = min(ans, dfs(v, -1, 0, k / 2));
        }
    }

    writeln(ans);
}



























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

//alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 636
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
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; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n;
  cin>>n;

  vector<string> p(n);
  vector<pair<int,int>> q(n,{0,0});
  rep(i,n){
    cin>>p[i];
  }

  rep(i,n){
    int l=p[i].size();
    int ten=-1;
    rep(j,l){
      if(p[i][j]=='.') ten=j;
    }
    if(ten==-1) {
      int sei=stoi(p[i]);
      while(sei%2==0){
      q[i].fi++;
      sei/=2;
      }
      while(sei%5==0){
      q[i].se++;
      sei/=5;
      }
      continue;
    }

    int x=l-1-ten;
    q[i].fi-=x;
    q[i].se-=x;
    string s=p[i].substr(0,ten);
    string t=p[i].substr(ten+1);
    s+=t;
    ll z=stoll(s);
    while(z%2==0){
      q[i].fi++;
      z/=2;
    }
    while(z%5==0){
      q[i].se++;
      z/=5;
    }
  }

  map<pair<int,int>,ll> ma;
  for(int i=-10;i<=10;i++){
    for(int j=-10;j<=10;j++){
      ma[{i,j}]=0;
    }
  }

  rep(i,n){
    if(q[i].fi>10) q[i].fi=10;
    if(q[i].se>10) q[i].se=10;
    ma[q[i]]++;
  }

  ll ans=0;

  for(int i=-10;i<=10;i++){
    for(int j=-10;j<=10;j++){
      for(int k=-10;k<=10;k++){
        for(int l=-10;l<=10;l++){
          if(i+k>=0 && j+l>=0){
            if(i!=k || j!=l){
              ans+=ma[{i,j}]*ma[{k,l}];
            }
          }
        }
      }
    }
  }  

  ans/=2;

  for(int i=-10;i<=10;i++){
    for(int j=-10;j<=10;j++){
      if(i>=0 && j>=0){
      ans+=ma[{i,j}]*(ma[{i,j}]-1)/2;
      }
    }
  }  

  cout << ans << endl;
}

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

int main()
{
    std::string S;
    std::cin >> S;

    if (S[2] == S[3] && S[4] == S[5])
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
    return 0;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bellman_ford(N: int, edges: list, src: int) -> list:
    """ ベルマンフォード(頂点数, 辺集合(0-indexed), 始点) """

    # 頂点[ある始点からの最短距離] (経路自体を知りたい時はここに前の頂点も持たせる)
    res = [INF] * N
    res[src] = 0
    # 各辺によるコストの置き換えを頂点数N-1回繰り返す
    for _ in range(N-1):
        for src, dest, cost in edges:
            if res[dest] > res[src] + cost:
                res[dest] = res[src] + cost
    ans = res[N-1]
    # 負の閉路(いくらでもコストを減らせてしまう場所)がないかチェックする
    for _ in range(N-1):
        for src, dest, cost in edges:
            if res[dest] > res[src] + cost:
                res[dest] = res[src] + cost
    if ans != res[N-1]:
        # あったら空リストを返却
        return []
    # 問題なければ頂点リストを返却
    return res

N, M = MAP()
edges = []
for i in range(M):
    a, b, c = MAP()
    a -= 1; b -= 1
    edges.append((a, b, -c))

res = bellman_ford(N, edges, 0)

if res:
    print(-res[N-1])
else:
    print('inf')


Measured memory_bytes: 3316
n = int(input())
dp = [[0 for _ in range(3)] for _ in range(n+1)]
abc = []

for i in range(1, n+1):
    abc.append([int(x) for x in input().split()])

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + abc[i][k])

ans = 0
for i in range(3):
    ans = max(ans, dp[n][i])
    
print(ans)

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

int main()
{
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	std::cout << std::fixed;
    std::cout << std::setprecision(10);
	cout<<(w*h)/2<<" ";

	if(x==w/2 && y == h/2)
	{
		printf("1\n");
	}
	else
		printf("0\n");

	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define show(v) for(int i : v)cout << i << " ";cout << endl;
#define sall(v) sort(v.begin(), v.end());

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int inf = 1e9;
int mod = 1e9 + 7;
const int MAXN = 100005;

//vector<int> g[MAXN];
//vector<bool> was;
//vector<int> d, a;
//int n, m, k, c;
//
//void dfs(int v) {
//    was[v] = true;
//    d[v] = c;
//    for(int to : g[v]){
//        if(!was[to]){
//            dfs(to);
//        }
//    }
//}
//
//
//void solve() {
//    cin >> n >> m >> k;
//    c = 0;
//    d.assign(n, 0);
//    a.assign(k, 0);
//    was.assign(n, false);
//    for(int i = 0;i < k;i++){
//        cin >> a[i];
//        a[i]--;
//    }
//    for(int i = 0;i < n;i++){
//        int x, y;
//        cin >> x >> y;
//        g[x].pb(y);
//        g[y].pb(y);
//    }
//    for(int i = 0;i < n;i++){
//        if(!was[i]){
//            dfs(i);
//            c++;
//        }
//    }
//
//}

int main(){
    faster
    int n; cin >> n;
    int step = 0;
    bool ok = false;
    for(int i = 0;i < n;i++){
        int x, y; cin >> x >> y;
        if(x == y)step++;
        else step = 0;
        if(step == 3)
            ok = true;
    }
    cout << (ok ? "Yes" : "No");
    return 0;
}


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

namespace abc132_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var dl = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).OrderBy(x => x).ToList();
            Console.WriteLine(dl[(N / 2)] - dl[(N / 2) - 1]);
        }
    }
}


Measured memory_bytes: 21728
/*input
869121
*/

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

// from atcoder live
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1e9+7;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
 
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    int n;
    cin >> n;
    mint a = 10, b = 9, c = 8;
    mint ans = a.pow(n)-b.pow(n)*2+c.pow(n);
    cout << ans << endl;
}

Measured memory_bytes: 3624
{-# LANGUAGE TupleSections #-}

import qualified Data.ByteString.Char8 as B
import           Data.Maybe (fromJust)
import qualified Data.Map.Strict as M
import           Control.Monad (replicateM)

modT :: Integer
modT = 1000000007

main :: IO ()
main = do
  n <- getInt
  m <- M.fromListWith (+) . fmap ((, 1) . convert) <$> replicateM n getIntegers
  print . solve $ m

convert [a, b]
  | a == 0 && b == 0 = (0, 0)
  | a == 0 = (0, 1)
  | b == 0 = (1, 0)
  | otherwise = let gcd' = gcd a b
                in if b < 0
                   then (-div a gcd', -div b gcd')
                   else (div a gcd', div b gcd')

solve :: M.Map (Int, Int) Int -> Integer
solve map = let zero = M.findWithDefault 0 (0, 0) map
                ans = solve' . M.delete (0, 0) $ map
            in (ans + fromIntegral zero - 1) `mod` modT

solve' :: M.Map (Int, Int) Int -> Integer
solve' map =
  if M.null map
  then 1
  else let ((a, b), count) = M.elemAt 0 map
           inv = if a > 0
                 then (-b, a)
                 else (b, -a)
           count' = M.findWithDefault 0 inv map
           ncount = solve' . M.delete (a, b) . M.delete inv $ map
           ccount = ((2 ^ count) `mod` modT + (2 ^ count' - 1) `mod` modT)
             `mod` modT
       in (ncount * ccount) `mod` modT

getInt = fst . fromJust . B.readInt <$> B.getLine

getIntegers = fmap (fst . fromJust . B.readInt) . B.words <$> B.getLine


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

int A, B;

signed main() {
	cin >> A >> B;
	for (int yen = 1; yen < 10000000; yen++) {
		// int a = yen * 0.08;
		// int b = yen * 0.1;
		int a = (yen * 8) / 100;
		int b = (yen * 10) / 100;
		// dbg3(yen, a, b)
		if (A == a and B == b) {
			cout << yen << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int M = keyboard.nextInt();
		int C = keyboard.nextInt();
		
		int[]B = new int[M];
		for(int i=0; i<M; i++){
			B[i] = keyboard.nextInt();
		}
		
		int[][]A = new int[N][M];
		for(int j=0; j<N; j++){
			for(int k=0; k<M; k++){
				A[j][k] = keyboard.nextInt();
			}
		}
		
		int culc = 0;
		int ans = 0;
		
		for(int n=0; n<N; n++){
			culc = 0;
			for(int m=0; m<M; m++){
				culc += A[n][m]*B[m];
				}
			if(culc+C>0){
				ans++;
			}
		}
		
		System.out.println(ans);
		keyboard.close();	
	}
}

Measured memory_bytes: 22100
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 1000000007 
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n;
	cin >> n;
	int c = 1;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if(x == c) {
			c++;
		}
	}
	if(c == 1) {
		cout << -1;
	}
	else {
		cout << n - (c - 1);
	}
}


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    ll a, b, k;
    cin >> k >> a >> b;
    frep(i, a, b) {
        if((i%k)==0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count))%MOD;
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}



Measured memory_bytes: 3624