akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    string S; cin >> S;
    int n = (int)S.size();
    const int M = 13;

    vector<vll> dp(n+1, vll(M));
    dp[0][0] = 1;
    rep(i, n){
        rep(j, M){
            ll& cur = dp[i][j];
            if(cur == 0) continue;

            rep(k, 10){
                if(S[i] != '?' and S[i] != (char)('0'+k)) continue;

                int num = j * 10 + k;
                int nj = num % M;
                ll& nxt = dp[i+1][nj];

                nxt = ADD(nxt, cur, mod);
            }
        }
    }

    cout << dp[n][5] << endl;

    return 0;
}


Measured memory_bytes: 13648
#include <stdio.h>

int main(void)
{
	int n,x[4][3][10],a,b,c,d,i,j,k,s,t,u;
	scanf("%d",&n);
	for(s=0;s<=3;s++)
	{
		for(t=0;t<=2;t++)
		{
			for(u=0;u<=9;u++)
			{
				x[s][t][u]=0;
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		scanf("%d%d%d%d",&a,&b,&c,&d);
		x[a-1][b-1][c-1]=x[a-1][b-1][c-1]+d;
	}
	for(i=1;i<=4;i++)
	{
		for(j=1;j<=3;j++)
		{
			for(k=1;k<=10;k++)
			{
				printf(" %d",x[i-1][j-1][k-1]);
			}
			printf("\n");
		}
		if(i==4)
		{
			break;
		}
		printf("####################\n");
	}
	return 0;
}

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

int n, k;
vector <int> a;

int main() {
    cin >> n >> k;
    a = vector <int> (n);
    rep (i, n) cin >> a[i];
    if ( n == k ) {
        cout << 1 << endl;
        return 0;
    }
    auto itr = find(a.begin(), a.end(), 1);
    int ans = 1e9;
    rep (i, k) {
        int left = (itr - a.begin() - i),
            right = ((int)(a.end() - itr - 1) - ((k - 1) - i));
        int res = 0;
        if (left  >= 0) res += left/(k - 1) + (left%(k - 1) != 0);
        if (right >= 0) res += right/(k - 1) + (right%(k - 1) != 0);
        ans = min( ans, res );
    }
    cout << ans + 1 << endl;

    return 0;
}


Measured memory_bytes: 768
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
	    int M = sc.nextInt();
	    long A [] = new long [N];
	    
	    for(int i = 0; i < N; i++) {
	    	A[i]=sc.nextLong();
	    }
	    Arrays.sort(A);
	   
	    TreeMap <Long, Long> store = new TreeMap <Long, Long>();
	    
		long Bi=0;
		long Ci=0;
		for (int i = 0; i<M; i++){
			Bi = sc.nextLong();
			Ci = sc.nextLong();
 
			if (store.containsKey(Ci)) 
				store.put(Ci, store.get(Ci) + Bi);
			 else 
				store.put(Ci, Bi);
			}
		sc.close();
		int right = 0;
		
		while (store.isEmpty()==false) {
			
			long c=store.lastKey();
			long b=store.lastEntry().getValue();
			
			long count = 0;
			while (right<(long)(N) && A[right]<c && count<b){
				A[right]=c;
				right++;
				count++;
			}
			
			
			store.pollLastEntry();
		}
		long sum [] = new long [N+2];
		long current = 0;
		
	    for(int i = 0; i < N; i++) {
	    	current = A[i]+current;
	    	sum [i+1]=current;
	    }
	    System.out.println(sum[N]);
		
		
	}

}


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

char f[10][10];

int main() {
    //ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);

    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++)
            cin >> f[i][j];
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(f[i][j] == '.')
                continue;
            for(int a = i + 1; a <= n; a++) {
                for(int b = 1; b < j; b++) {
                    if(f[a][b] == '#') {
                        cout << "Impossible\n";
                        return 0;
                    }
                }
            }
            for(int a = 1; a < i; a++) {
                for(int b = j + 1; b <= m; b++) {
                    if(f[a][b] == '#') {
                        cout << "Impossible\n";
                        return 0;
                    }
                }
            }
        }
    }
    cout << "Possible\n";
    return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
         
        int r = stdIn.nextInt();
        int c = stdIn.nextInt();
         
        int[][] h = new int[r+1][c+1];
         
        for(int i = 0; i < r; i++) {
            int rsum = 0;
            for(int j = 0; j < c; j++) {
                int tmp = stdIn.nextInt();
                rsum += tmp;
                h[i][j] = tmp;
            }
            h[i][c] = rsum;
        }
         
        for(int i = 0; i < c+1; i++) {
            int rsum = 0;
            for(int j = 0; j < r; j++) {
                rsum += h[j][i];
            }
            h[r][i] = rsum;
        }
         
        for(int i = 0; i < r+1; i++) {
            for(int j = 0; j < c; j++) {
                System.out.print(h[i][j] + " ");
            }
            System.out.println(h[i][c]);
        }
    }
}


Measured memory_bytes: 43900
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

bool check(char a, char b) {
	return a > b;
}

int kuraiwa(int n) {
	int ans = 0;
	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}
	return ans;
}

bool kaibun(int n) {
	int a[5];
	for (int i = 0; i < 5; i++) {
		a[i] = n % 10;
		n /= 10;
	}
	if (a[0] == a[4] && a[1] == a[3]) {
		return true;
	}
	else {
		return false;
	}
}

int main() {
	int a, b;
	cin >> a >> b;
	int cnt = 1;
	rep(i, a){
		cnt*=100;
	}
	if (b == 100){
		b++;
	}
	cout << cnt*b << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  998244353
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()


signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int x,y,z;
   cin>>x>>y>>z;
   cout<<z<<" "<<x<<" "<<y<<endl;
}


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

#define long long ll
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
typedef pair<int,int>P;


int main(){
	
	
	int n;
	cin>>n;
	
	set<int>v[n+1];
	
	int ans=0;
	for(int i=1;i<=n;i++){
		int tmp;
		cin>>tmp;
		if(v[i].find(tmp)!=v[i].end()){
			ans++;
		}
		v[tmp].insert(i);
	}
	
	cout<<ans<<endl;
	
	return 0;
}


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

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

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

    int y = 1000 * (s[0] - '0') + 100 * (s[1] - '0') + 10 * (s[2] - '0') + (s[3] - '0');
    int m = 10 * (s[5] - '0') + (s[6] - '0');
    int d = 10 * (s[8] - '0') + (s[9] - '0');

    if (y < 2019)
    {
        cout << "Heisei" << endl;
        return 0;
    }
    if (m < 5)
    {
        cout << "Heisei" << endl;
        return 0;
    }
    cout << "TBD" << endl;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
A.sort()

ans1 = A[-1]
ans2 = -1
if(A[-1]%2 == 1): tmp1,tmp2 = A[-1]//2,A[-1]//2 + 1
else: tmp1,tmp2 = A[-1]//2,A[-1]//2
min_dif = float('inf')

for i in range(n):
 if(min_dif > abs(A[i]-tmp1)):
  min_dif = abs(A[i]-tmp1)
  ans2 = A[i]
 if(min_dif > abs(A[i]-tmp2)):
  min_dif = abs(A[i]-tmp2)
  ans2 = A[i]   
  
print(ans1,ans2)

Measured memory_bytes: 14428
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
while True:
	H,W=map(int,input().split())
	if H==0 and W==0:
		break
	print("#"*W)	
	for i in range(H-2):
		print("#"+"."*(W-2)+"#")
	print("#"*W)
	print()


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

int main() {
  int A, B, C, K; cin >> A >> B >> C >> K;
  int ans;
  if (K <= A) ans = K;
  else if (A < K && K <= A+B) ans = A;
  else ans = -K + B +2*A;
  cout << ans << endl;
}

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

void Main()
{
	int N; cin >> N;
	vector<int> V(N);
	vector<int> C(N);
	rep(i,N) cin >> V[i];
	rep(i,N) cin >> C[i];
	vector<int> vec;
	rep(i,N) {
		vec.push_back(V[i] - C[i]);
	}
	int res = 0;
	for (int v : vec) {
		if (v > 0) res += v;
	}
	cout << res;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	string s[2];
	cin >> s[0] >> s[1];
	if(s[0][0] == s[1][2] && s[0][1]==s[1][1] && s[1][0]==s[0][2]){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

struct Point {
    double x, y;
};

int main() {
    int N; cin >> N;
    vector<int> P(N);
    for (int i = 0; i < N; i++) P[i] = i + 1;
    vector<Point> Q(N + 1);
    for (int i = 1; i <= N; i++) {
        cin >> Q[i].x >> Q[i].y;
    }

    double sum = 0;
    int cnt = 0;
    do {
        cnt++;
        for (int i = 1; i < N; i++) {
            sum += sqrt(pow(abs(Q[P[i - 1]].x - Q[P[i]].x), 2) + pow(abs(Q[P[i - 1]].y - Q[P[i]].y), 2));
        }
    } while (next_permutation(P.begin(), P.end()));

    double ave = sum / cnt;
    printf("%.10lf\n", ave);
    return 0;
}

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

mx = int(n ** 0.5)
ans = 10

for i in range(1, mx + 1):
    if n % i == 0:
        la = len(str(i))
        lb = len(str(n // i))
        if max(la, lb) < ans:
            ans = max(la, lb)

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int x=0;
    int dig,num=n;
    while(n){
        dig=n%10;
        x+=dig;
        n/=10;
    }
    if(num%x==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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; }

int main() {
    int r;
    cin >>r;
    cout << r*r << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, K; cin >> N >> K;
    vector<int> a(N);
    for(int i = 0; i < N; i++ ) cin >> a[i];
 
    bool dp[100001] = {0}; 
    for(int i = 0; i < a[0] ; i++) dp[i] = false;
 
    for(int i = a[0]; i <= K; i++){
        dp[i] = false;
        for(int j = 0; j < N; j++){
            if(i - a[j] >= 0 && dp[i - a[j]] == false){
                dp[i] = true;
                break;
            }
        }
    }
    if( dp[K] ) cout << "First\n";
    else cout << "Second\n";
}

Measured memory_bytes: 512
def main():
    import sys
    input = sys.stdin.readline

    n = int(input())

    if n % 2 == 1:
        print(0)
    else:
        c = 0
        for i in range(1,100):
            c += (n//(2*(5**i)))
        print(c)
        



if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int(i)=(a);(i)<(b);++(i))
#define RREP(i,a,b) for(int(i)=(a)-1;(i)>=(b);--(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;

ll H,W;

int main()
{
  cin >> H >> W;
  ll res;
  if (H == 1 || W == 1) res = 1;
  else res = (H * W + 1) / 2;
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int calcCost(int n,vector<vector<int> >c,vector<bool>went,vector<int>costs){
  int i=0;
  int minn = c[n][1];
  went[n] = true;
  if(costs[n]!=-1)return costs[n];
  else{
  if(n==1)return 0;
  else{
    for(i=0;i<=9;i++){
    if(!went[i]){
      minn = min(minn,calcCost(i,c,went,costs)+c[n][i]);
    }
  }
  return minn;
}}
}

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<int> >c(10,vector<int>(10));
  vector<vector<int> >a(h,vector<int>(w));
  vector<bool>went(10,false);
  vector<int>costs(10,-1);
  int i,j;
  for(i=0;i<10;i++){
    for(j=0;j<10;j++){
      cin >> c[i][j];
    }
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin >> a[i][j];
    }
  }
  for(i=0;i<10;i++){
    costs[i] = calcCost(i,c,went,costs);
  }
  long anss = 0;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(a[i][j]!=-1)anss += costs[a[i][j]];
    }
  }
  cout << anss << endl;



}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int llint
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI (acos(-1))
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using Complex = std::complex<double>;
using namespace std;


int N;
MII m;


signed main(){
	cin >> N;
	rep(i, 0, N){
		int a;
		cin >> a;
		m[a]++;
	}

	int ans = 0;
	for(PII p : m)
		if(p.fi <= p.se) ans += p.se-p.fi;
		else ans += p.se;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6272
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    ll x, y;
    cin >> x >> y;
    if (abs(x - y) > 1) cout << "Alice";
    else cout << "Brown";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a,b,c,i,j,p=0;
	char x[50];
	for(i=0;i<50;i++){
	cin>>a>>b>>c;
	if(a==-1&&b==-1&&c==-1){
	break;
	}
	p++;
	if(a==-1||b==-1||a+b<30){
		x[i]='F';
	}
	else if(a+b>=80){
	x[i]='A';
	}
	else if(a+b>=65&&a+b<80){
	x[i]='B';
	}
	else if(a+b>=50&&a+b<65){
	x[i]='C';
	}
	else if(a+b>=30&&a+b<50){
		if(c>=50){
		x[i]='C';
		}
		else{
		x[i]='D';
		}
	}
	}
	for(j=0;j<50;j++){
	cout<<x[j]<<endl;
	if(j==p-1){
	break;
	}
	}
        return 0;
    }


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
int main() {
    int X, Y;
    cin >> X >> Y;
    cout << (X + Y / 2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; int t;
	cin >> n;
	cin >> t;
	int aux1, aux2;
	int costAux = 1001;
	while(n--){
		cin >> aux1;
		cin >> aux2;
		if(aux2 <= t) {
			if(aux1 < costAux) {
				costAux = aux1;
			}		
		}
	}
	if(costAux == 1001) cout << "TLE"; else cout << costAux;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

int main() {
    int a,b;
    cin>>a>>b;
    if(a>=1 && a<=9 && b>=1 && b<=9)cout<<a*b<<endl;
    else cout<<"-1"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s;
    cin>>s;
    ll cnt=0;
    ll sum=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='W')
        {
             cnt++;
             sum+=i;
        }
    }
    for(int i=0;i<cnt;i++)
    {
        sum-=i;
    }
    cout<<sum<<endl;

}


Measured memory_bytes: 3732
#include <stdio.h>
/********
*	??¨?¨????
*********/

/*********??¢?????´?????????
*	(1)???????????\??????????????????????????´?????\??????????????§?????????????????????
*	(2)
*********/

int main(void)
{
	int r, c ;			//??¨????????°r??¨?????°c
	int gyouretsu[101][101]={{0}} ;	//??????
	int i, j;
	int youso;			//?????????????´?
	int total = 0;		//???????¨???¨???????¨???????????¨?
	int gyou_goukei ;	//???????¨?
	int retsu_goukei ;	//???????¨?

	
	scanf("%d %d\n", &r, &c);	//?????°??¨?????°?????\???
	
	for(i = 0 ; i < r  ; i++ ){		//???????????\???
		for( j= 0 ; j < c ; j++ ){
			
			scanf("%d", &youso);
			gyouretsu[i][j] = youso;
		}
		scanf("\n");
	}
//-------------------------------------------------	
	for(i = 0 ; i <= r  ; i++ ){		//??????????¨????????¨????
	    gyou_goukei = 0;
		for( j = 0 ; j < c ; j++ ){	
			gyou_goukei += gyouretsu[i][j];
		
		}
		gyouretsu[i][c] = gyou_goukei;
	}
	
	for(j = 0 ; j <= c  ; j++ ){		//??????????¨????????¨????
		retsu_goukei = 0;
		for( i = 0 ; i < r ; i++ ){	
			retsu_goukei += gyouretsu[i][j];

	    }
    	gyouretsu[r][j] = retsu_goukei;
    }


//-------------------------------------------------	
								//?????°??¨?????°???1????¢??????????????????????
	for(i = 0 ; i <= r  ; i++ ){
		for( j= 0 ; j <= c ; j++ ){
			printf("%d", gyouretsu[i][j]);
			if(j < c){
				printf(" ");	//1???????????¨?????????
			} else if(j == c){
				printf("\n");	//?????????????????§??????
			}else {
				//??????????????\??????
			}
		}
	}
    return 0;
	
}

Measured memory_bytes: 1084
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

S = input()

if 'a' in S and 'b' in S and 'c' in S:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38384
import sys
sys.setrecursionlimit(10**7)
from queue import Queue

def input():
    return sys.stdin.readline()

N, Q = map(int, input().split())
adj = [[] for _ in range(N+1)]
for _ in range(N-1):
    x, y = map(int, input().split())
    adj[x].append(y)
    adj[y].append(x)

score = [0 for _ in range(N+1)]
for _ in range(Q):
    p, x = map(int, input().split())
    score[p] += x

def dfs(now, prev):
    for target in adj[now]:
        if target == prev:
            continue
        score[target] += score[now]
        dfs(target, now)

dfs(1, 0)

print(" ".join(map(str, score[1:])))


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

int main(void){
  int N;
  long s=1;
  long Mod = 1e+09 +7;
  cin >> N;
  for (int i = 1; i<= N; i++){
    s = s* (long)i % Mod;
  }
  cout << s << endl;
}
  

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cout<<#x<<" = "<<x<<endl;
#define lowbit(x) x&(-x)
#define PA pair<int, int>
#define MK make_pair
using namespace std;
typedef long long LL;
inline int read()
{
	int l = 0, f = 1;
	char a = getchar();
	for (; a < '0' || a > '9'; a = getchar())
		if (a == '-') f = -1;
	for (; a >= '0' && a <= '9'; a = getchar())
		l = l*10+a-48;
	return l*f;
}
const int N = 100005;
struct Edge
{
	int v, next;
}e[N*10];
int n, m, num, cnt, tot, h[N], c[N], vis[N];
vector <int> a, b;
void insert(int u, int v)
{
	e[++num].v = v, e[num].next = h[u], h[u] = num;
	e[++num].v = u, e[num].next = h[v], h[v] = num;
}
void dfs(int x)
{
	if (vis[x]) return;
	a.push_back(c[x]);
	vis[x] = 1;
	for (int i = h[x]; i; i = e[i].next)
		dfs(e[i].v);
}
int main(int argc, char const *argv[])
{
	n = read(), m = read();
	if (n < 2*(n-m-1))
	{
		printf("Impossible\n");
		return 0;
	}
	if (m == n-1)
	{
		printf("0\n");
		return 0;
	}
	for (int i = 0; i < n; ++i) c[i] = read();
	for (int i = 0; i < m; ++i)
	{
		int u = read(), v = read();
		insert(u, v);
	}
	LL ans = 0;
	for (int i = 0; i < n; ++i)
	{
		if (vis[i]) continue;
		dfs(i);
		sort(a.begin(), a.end());
		ans += a[0];
		for (int j = 1; j < a.size(); ++j) b.push_back(a[j]);
		a.clear();
		++tot;
	}
	sort(b.begin(), b.end());
	for (int i = tot; i < 2*(n-m-1); ++i) ans += b[i-tot];
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 5496
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
 
struct Edge {
    long long to;
};
using Graph = vector<vector<Edge>>;
 
int encode(int i, int j) {
    if (i < j) swap(i, j);
    return i * (i - 1) / 2 + j + 1;
}
 
int seen[2000000];  // 1:現在探索中のパスで行きがけ 2:探索後の頂点
int d[2000000];     // d[i]:= 始点から i への距離
int dfs(const Graph &G, int now) {
    if (seen[now] == 2) return d[now];
    seen[now] = 1;
    for (auto e : G[now]) {
        if (seen[e.to] == 1) {  // 閉路を検出
            cout << -1 << endl;
            exit(0);
        }
        chmax(d[now], dfs(G, e.to) + 1);
    }
    seen[now] = 2;
    return d[now];
}
 
int main() {
    long long N;
    cin >> N;
    Graph G(N * (N - 1) / 2 + 1);
    FOR(i, 0, N) {
        int now = 0;
        LOOP(N - 1) {
            int j;
            cin >> j;
            j--;
            int next = encode(i, j);
            G[now].push_back({next});
            now = next;
        }
    }
 
    cout << dfs(G, 0) << endl;
    return 0;
}

Measured memory_bytes: 33664
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);
ll const MAX = 1e5 + 5;
ll ans[MAX];
vector<vector<pll>> g(MAX+1, vector<pll>());

void dfs(ll cur, ll n, ll p, ll t){
        ll xxx = 1;
        for(auto x:g[cur]){
                ll nex = x.first;
                ll name = x.second;
                if(nex == p){
                        continue;
                }
                if(xxx == t){
                        xxx++;
                }
                ans[name] = xxx;
                xxx++;
                dfs(nex, n, cur, ans[name]);
        }
}

int main(){
        ll n;
        cin >> n;
        REP(i,1,n-1){
                ll a,b;
                cin >> a >> b;
                g[a].push_back({b,i});
                g[b].push_back({a, i});
        }
        ll num = 0;
        REP(i,1,n){
                num = max(num, SIZE(g[i]));
        }
        
        dfs(1, n, -1, -1);
        cout << num << endl;
        REP(i,1,n-1){
                cout << ans[i] << endl;
        }
}

Measured memory_bytes: 10752
import java.util.Scanner;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

public class Main {

	private static final Integer SEVEN = 7;

	public static void main(String[] args) throws ScriptException {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] abcd = scanner.next().toCharArray();
			for (int i = 0; i < pow(2, abcd.length) - 1; i++) {
				if (ok(abcd, i)) {
					System.out.println(toFormula(abcd, i) + "=" + SEVEN);
					return;
				}
			}
		}
	}

	/**
	 * nのmべき乗を返す
	 * 
	 * @param n
	 * @param m
	 * @return nのmべき乗
	 */
	private static int pow(int n, int m) {
		int result = 1;
		while (m > 0) {
			if (1 == (m & 1)) {
				result *= n;
			}
			n *= n;
			m >>= 1;
		}
		return result;
	}

	/**
	 * abcdと'+'か'-'を表す二進数で数式を組み立てて、結果が7かどうかを判定
	 * 
	 * @param abcd
	 * @param n    '+'か'-'を表す二進数
	 * @return 結果が7かどうか
	 */
	private static boolean ok(char[] abcd, int n) throws ScriptException {
		ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
		return SEVEN.equals(engine.eval(toFormula(abcd, n)));
	}

	/**
	 * abcdと'+'か'-'を表す二進数で数式を組み立てる
	 * 
	 * @param abcd
	 * @param n    '+'か'-'を表す二進数
	 * @return a?b?c?d の数式
	 */
	private static String toFormula(char[] abcd, int n) {
		StringBuilder result = new StringBuilder();
		for (char c : abcd) {
			result.append(c);
			result.append((1 == (n & 1)) ? '+' : '-');
			n >>= 1;
		}
		// 最後の文字を削除
		result.deleteCharAt(result.length() - 1);
		return result.toString();
	}
}


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

using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	ll N; cin>>N;
	vector<ll> A(N);
	ll ans=0,mem=0;
	rep(i,N)cin>>A[i];
	
	rep(i,N){
		ll p=(A[i]+mem)/2;
		ans+=p;
		if(p==0 && mem==1) mem=0;
		else{
			mem=A[i]+mem-2*p;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long a = in.nextLong();
            long b = in.nextLong();
            long c = in.nextLong();
            long x = in.nextLong();
            long y = in.nextLong();

            long ans = Long.MAX_VALUE;
            for (long i = 0; i < 100001; i++) {
                long tmp = 0;
                tmp += 2 * c * i;
                tmp += a * Math.max(0, x - i);
                tmp += b * Math.max(0, y - i);

                ans = Math.min(ans, tmp);
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define MOD 1000000007
#define pb push_back
#define ll long long
using namespace std;
const int nmax=101234;

int n,k,a[112],dp[nmax];

int main()
{
    scanf("%d %d",&n,&k);
    for(int i=0; i<n; ++i)
    {
        scanf("%d",&a[i]);
    }
    for(int i=1; i<=k; ++i)
    {
        for(int j=0; j<n && a[j]<=i; ++j)
        {
            if(dp[i-a[j]]==0)
            {
                dp[i]=1;
                break;
            }
        }
    }
    if(dp[k]==1)
        printf("First");
    else
        printf("Second");
    return 0;
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[] a = new int[n];
			for(int i=0;i<n;i++)a[i]=sc.nextInt();
			Arrays.sort(a);
			long s = 0;
			long t = 0;
			for(int i=0;i<n;i++){
				s += t;
				t += a[i];
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 45028
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
//#define local
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    int n,m,sum=0,T[110];
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>T[i];
        sum+=T[i];
    }
    cin>>m;
    for(int i=0; i<m; i++)
    {
        int p,x;
        cin>>p>>x;
        cout<<sum-T[p]+x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
int main(void){
	using namespace std;
	string S;
	cin >> S;
	int c1 = 0, c0 = 0;
	int n = S.size();	
	for(int i = 0; i < n; i++){
		if(i % 2 == 0){
			if( S[i] == '0'){
				c0++;
			}else{
				c1++;
			}
		}else{
			if( S[i] == '0'){
				c1++;
			}else{
				c0++;
			}
		}
	}
	cout << (int)((c0 > c1) ? c1 : c0);
	
}


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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 323;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int a[N][N];
int u[N];
int c[N];
int ans;


inline void process () {
	int res = 0;
	memset(c, 0, sizeof (c));

	for (int i = 1; i <= n; i ++) {
		
		for (int j = 1; j <= m; j++) if (!u[a[i][j]]) {
			c[a[i][j]]++;
			break;
		}
	}
	for (int i = 1; i <= m; i++) if (c[i] > c[res]) {
		res = i;
	}
	ans = min(ans, c[res]);
	u[res] = 1;
}

int main () {
	SpeedForce;
	cin >> n >> m;
	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= m; ++j) {
			cin >> a[i][j];
		}
	}
	ans = n;
	for (int it = 1; it < m; ++it) {
		process();
	}

	cout << ans << '\n';
   	return Accepted;
}

// B...a

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
b = list(map(abs, a))
b.sort()

num = 0
for i in range(n):
    if a[i] < 0:
        num = num + 1
if num % 2 == 0:
    ans = sum(b)
else:
    ans = sum(b) - (b[0]*2)
print(ans)

Measured memory_bytes: 14284
#include <iostream>
#include <cstring>

using namespace std;

bool mp[1002][1002];
int count[1002][1002];
int main(){
    int h,w,n;
    while(cin>>h>>w>>n,h){
        for(int i=0;i<h;++i){
            for(int j=0;j<w;++j){
                cin>>mp[i][j];
            }
        }
        memset(count,0,sizeof(count));
        count[0][0]=n-1;
        for(int i=0;i<h;++i){
            for(int j=0;j<w;++j){
                mp[i][j]=mp[i][j]^(count[i][j]%2);
                count[i][j+1] += (count[i][j]+!mp[i][j])/2;
                count[i+1][j] += (count[i][j]+mp[i][j])/2;
            }
        }
        int x=0,y=0;
        while(x<w&&y<h){
            if(mp[y][x]) ++x;
            else ++y;
        }
        cout<<y+1<<" "<<x+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 7908
N = int(input())
A = [[int(n) for n in input().split()] for _ in range(2)]
ans = 0
for i in range(N):
    c = 0
    d = 0
    for j in range(N):
        c += A[d][j]
        if i == j:
            d = 1
            c += A[d][j]

    ans = max(ans, c)

print(ans)

Measured memory_bytes: 3064
N, M  = map(int, input().split())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n = make_divisors(N)
m = make_divisors(M)

res = set(n) & set(m)

res = list(res)

res.sort()


def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

result = 0
for i in range(len(res)):
    if is_prime(res[i]):
        result += 1


print(result+1)


Measured memory_bytes: 5248
s = list(input())
x, y = map(int, input().split())

z = [0]
for i in s:
    if i=='F':
        z[-1] += 1
    else:
        z.append(0)
_y = len(z)//2
_x = len(z) - _y
len_s = len(s)
dp_x = [0 for _i in range((2*len_s+2))]
dp_x_to = [0 for _i in range((2*len_s+2))]
dp_y = [0 for _i in range((2*len_s+2))]
dp_y_to = [0 for _i in range((2*len_s+2))]

dp_x[z[0]] = 1
dp_y[0] = 1

for i in range(1, len(z)):
    if i%2==0:
        for j in range(-len_s, len_s+1):
            dp_x_to[j] = max(
                dp_x[j-z[i]],
                dp_x[j+z[i]]
            )
        dp_x = dp_x_to.copy()
    else:
        for j in range(-len_s, len_s+1):
            dp_y_to[j] = max(
                dp_y[j-z[i]],
                dp_y[j+z[i]]
            )
        dp_y = dp_y_to.copy()

if dp_x[x] == dp_y[y] == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 88644
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

const int64_t MOD = 1e9 + 7;

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

    vector<vector<int64_t>> dp(n, vector<int64_t>(n));
    vector<int64_t> dpsum(n + 1);
    rep(i, n)
    {
        if (i == 0) {
            rep(j, n)
            {
                dp[i][j] = j == 0 ? 1 : 0;
            }
        } else {
            rep(j, n)
            {
                if (j > i) {
                    dp[i][j] = 0;
                } else {
                    if (s[i - 1] == '>') {
                        dp[i][j] = (dpsum[i] - dpsum[j] + MOD) % MOD;
                    } else {
                        dp[i][j] = (dpsum[j] - dpsum[0] + MOD) % MOD;
                    }
                }
            }
        }
        dpsum[0] = 0;
        rep(j, n)
        {
            dpsum[j + 1] = (dpsum[j] + dp[i][j]) % MOD;
        }
    }
    cout << dpsum[n] << endl;

    return 0;
}

Measured memory_bytes: 70656
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
	const auto half = [](int a) {return a >> 1; };
	const auto halfl = [](ll a) { return a >> 1; };
	string s; cin >> s;
	int k; cin >> k;
	bool all_same = true;
	for (int i = 0; i < s.length() - 1; ++i)
		all_same &= s[i] == s[i + 1];
	if (all_same)
		cout << halfl((ll)(s.length()) * k) << endl;
	else {
		vector<int> separate;
		int l = 0, ptr = 1;
		while (l < s.length()) {
			if (ptr == s.length() || s[ptr] != s[ptr - 1]) {
				separate.push_back(ptr - l);
				l = ptr;
			}
			++ptr;
		}
		ll res = 0;
		if (s[0] != s[s.length() - 1]) {
			for (auto i : separate)
				res += (ll)k * half(i);
			cout << res << endl;
		}
		else {
			int sz = separate.size();
			res += half(separate[0]);
			res += half(separate[sz - 1]);
			for (int i = 1; i < sz - 1; ++i)
				res += (ll)k * half(separate[i]);
			int b = separate[0] + separate[sz - 1];
			res += (k - 1LL) * half(b);
			cout << res << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
// She is Pretty pretty!
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

const int N = 1e6+100;
int n ;
double p[N], dp[N];
int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> p[i];
    }
    dp[0] = 1.0;
    for(int i = 1; i <= n; i++){
        for(int j = i; j >= 1; j--){
            dp[j] = (dp[j] * (1.0-p[i]) + dp[j-1]*p[i]);
            //dp[0] *= 1.0-p[i];
        }
        dp[0] *= 1.0 - p[i];
    }
    /*for(int i = 1; i <= n; i++){
        printf("%.6f\n",dp[i]);
    }*/
    double ans = 0.0;
    for(int i = n/2 + 1; i <= n; i++){
        ans += dp[i];
    }
    printf("%.10f",ans);
    return 0;
}

Measured memory_bytes: 2304
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
    int a[3],x=0,y=0,z=0;
    while(scanf("%d%d%d",&a[0],&a[1],&a[2])!=EOF){
        sort(a,a+3);
        if(a[0]+a[1]<=a[2])break;
        if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2])x++;
        else if(a[0]*a[0]+a[1]*a[1]<a[2]*a[2])y++;
        else z++;
    }
    printf("%d %d %d %d\n",x+y+z,x,z,y);
}


Measured memory_bytes: 2792
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int N=200010;
int a[N],b[N],dp[N];
int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	int n;int i,j,now;
	scanf("%d",&n);
	//if(n==1){printf("First\n");return 0;}
	rep(i,1,n)	scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	rep(i,1,n)	b[i]=a[i]-a[i-1];
	for(now=0,i=1;i<=n&&now<=n+10;i++){
		if(now>1&&(b[i]&1)==0&&dp[now-1]==1&&dp[now-2]==1)	dp[now-1]=0;
		for(j=0;j<=b[i]&&now<=n+10;j++,now++)	dp[now]=!((b[i]-j)&1);
	}
	//rep(i,0,now-1)	printf("%d\n",dp[i]);
	//rep(i,1,now)	if(dp[i]==0&&dp[i-1]==0)	dp[i]=1;	
	if(dp[n-1]==1)	printf("First\n");
	else printf("Second\n");
}
	

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

#define Bye return 0
#define ll long long
const ll M = 1e9+7;
const ll SIZE = 2e5+1;
vector<ll> ps(SIZE, 0); 
int e, n;
ll res = 0;

int scan(){
    scanf("%d", &e);
    return e;
}

void solve(){
    cin>>n;
    for (int i=1; i<=n; i++){
        ps[i] = (ps[i-1] + scan()*1ll)%M;
        res = (res%M + (e*ps[i-1])%M)%M;
    }
    cout<<res<<endl;
}

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

Measured memory_bytes: 4660
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <numeric>
#include <algorithm>
#include <queue>
#include <vector>

int main(void){
    long n;
    long m;
    std::cin >> n >> m;
    std::priority_queue<long, std::vector<long>, std::less<long> > items;
    for (int i = 0; i < n; i++){
        long tmp;
        std::cin >> tmp;
        items.push(tmp);
    }

    while (m > 0){
        double tmp = items.top();
        tmp = floor((1.0*tmp) * 0.5);
        items.pop();
        items.push((long)tmp);
        m--;

    }

    long sum = 0;
    for (long i = 0; i < n; i++){
        sum += items.top();
        items.pop();
    }

    printf("%ld\n", sum);
    return 0;
}

Measured memory_bytes: 1400
N = int(input())
D = list(map(int, input().split()))

res=[]
for i in range(len(D)-1,0,-2):
    res.append(D[i])
res.append(D[0])
start=(N+1)%2+1
for i in range(start,len(D),2):
    res.append(D[i])

for i in res:
    print(i,end=" ")

Measured memory_bytes: 25156
S = input()

sub_str = ['A', 'C', 'G', 'T']

count = 0
ans = 0
for s in S:
    if s in sub_str:
        count += 1
    else:
        ans = max(ans, count)
        count = 0
else:
    ans = max(ans, count)
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) ((int)(x).size())
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int inf = 1 << 30;
const ll INF = 1LL << 60;

int main(){
    int n;
    ll a, b;
    cin >> n >> a >> b;
    VL h(n);
    rep(i,n) cin >> h[i];

    ll ok = 1e9, ng = 0;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        auto f = [&]{
            ll cnt = mid;
            rep(i,n){
                ll rh = h[i] - b * mid;
                if (rh <= 0) continue;
                else cnt -= (rh + (a-b-1)) / (a-b);
            }
            if (cnt < 0) return false;
            else return true;
        };

        if (f()) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
ll a;
int main()
{
	priority_queue<int,vector<int>,less<int> >q;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		q.push(a);
	}
	for(int i=1;i<=m;i++)
	{
		ll qq=q.top();
		q.pop();
		qq=qq/2;
		q.push(qq);
	}
	ll sum=0;
	for(int i=1;i<=n;i++)
	{
		ll qq=q.top();
		q.pop();
		sum=sum+qq;
	}
	printf("%lld",sum);
	return 0;
}

Measured memory_bytes: 892