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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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 UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int ans = 0, mx = 0;
  for (int i = 0; i < 5; i++) {
    int tmp;
    cin >> tmp;
    ans += (tmp + (10 - tmp % 10) % 10);
    chmax(mx, (10 - tmp % 10) % 10);
  }

  cout << ans - mx << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <deque>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
		int N;
		cin >> N;
  	unordered_map<long long, bool> A;
		for (int i = 0; i < N; i++)
		{
            long long Ai;
            cin >> Ai;
						if (A[Ai]) {
                            cout << "NO" << endl;
                            return 0;
                        }
                        A[Ai] = true;
        }

        cout << "YES" << endl;
        return 0;
}


Measured memory_bytes: 11260
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
using namespace std;

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

int main(int argc, char* argv[]) {

	int k;
	cin >> k;

	if (k <= 9) {
		cout << k << endl;
		return 0;
	}


	set<ll> s;
	for (int i = 0; i < 9; i++) {
		s.insert(i+1);
	}

	int cnt = 9;
	while (1) {
		set<ll> newS;
		for (auto it = s.begin(); it != s.end(); it++) {
			ll num = *it;

			int n0 = num % 10;

			for (int i = -1; i <= 1; i++) {
				if (n0 + i < 0 || n0 + i >9) {
					continue;
				}

				if (cnt == k - 1) {
					cout << (num * 10 + n0 + i) << endl;
					return 0;
				}

				newS.insert(num * 10 + n0 + i);
				cnt++;
			}


		}

		s = newS;


	}

}

Measured memory_bytes: 7688
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){
	double a,b,c,degree,S;
	scanf("%lf %lf %lf",&a,&b,&degree);
	S = (0.5)*a*b*sin(M_PI*degree/180);
	c = sqrt(a*a+b*b-2*a*b*cos(M_PI*degree/180));
	printf("%.8lf\n",S);
	printf("%.8lf\n",a+b+c);
	printf("%.8lf\n",2*S/a);
}





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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const long long inf = 1e9+7;
const long long mod = 1e9+7;

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

    vector<int>a(n);
    rep(i,n)cin>>a[i];

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

    int ans=inf;

    rep2(i,-100,100){
        int sum=0;
        rep(j,n){
            sum+=pow(abs(a[j]-i),2);
        }

        ans=min(ans,sum);
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3604
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int a,b;
  cin>>a>>b;
  if(a*b%2==0)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
      
}

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

int n, h[100010];
bool dp[100010][2];
bool f;

int main(){
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> h[i];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = dp[0][1] = true;
	for (int i = 1; i <= n; ++i){
		dp[i][0] = (h[i-1] <= h[i] && dp[i-1][0]) || (h[i-1] - 1 <= h[i] && dp[i-1][1]);
		dp[i][1] = (h[i-1] <= h[i] - 1 && dp[i-1][0]) || (h[i-1] - 1 <= h[i] - 1 && dp[i-1][1]);
		if (!dp[i][0] && !dp[i][1]) break;
	}
	cout << ((dp[n-1][0] || dp[n-1][1]) ? "Yes": "No");
}

Measured memory_bytes: 768
n = int(input())
A = [[0]*10 for _ in range(10)]
for i in range(1, n+1):
  t = str(i)
  a, b = int(t[0]), int(t[-1])
  A[a][b] += 1
ans = 0
for i in range(1, 10):
  for j in range(1, 10):
    ans += A[i][j] * A[j][i]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 **/

int main(){
    int mod=1000000007;
    int n,m;
    for (int i=1;i<10;i++) {
        for (int j=1;j<10;j++) {
            printf("%dx%d=%d\n",i,j,i*j);
        }
    }
    return 0;
}

Measured memory_bytes: 3232
import java.util.Scanner

object Main {
  val sc = new Scanner(System.in)
  def main(args: Array[String]): Unit={
    val n  = sc.nextInt
    val y  = sc.nextInt
    val ix = Vector.fill(n)(sc.nextInt)

    val xl  = ix.map(x => Math.abs( x - y))

    val res = xl.foldLeft(0)(gcd(_,_))

    println(res)
  }
  
  def gcd(a: Int, b: Int): Int ={
    (a,b) match{
      case (x,y) if y == 0 => x
      case (x,y) if x < y  => gcd(y, x)
      case (x,y)           => gcd(y, x % y)
    }
  }}

Measured memory_bytes: 66332
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	static int n;
	static List<List<Integer>> list;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		list = new ArrayList<>(n);
		for(int i = 0; i < n; i++) list.add(new ArrayList<>());
		for(int i = 0; i < n - 1; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			list.get(a).add(b);
			list.get(b).add(a);
		}
		int[] list1 = dfs(0, -1, new int[n]);
		int[] list2 = dfs(n - 1, -1, new int[n]);
		int a = 0, b = 0;
		for(int i = 0; i < n; i++) {
			if(list1[i] <= list2[i]) a++;
			else b++;
		}
		if(a > b) {
			System.out.println("Fennec");
		} else {
			System.out.println("Snuke");
		}
//		System.out.println(Arrays.toString(list1));
//		System.out.println(Arrays.toString(list2));
	}

	static int[] dfs(int s, int p, int[] ret) {
		List<Integer> edge = list.get(s);
		for(int v : edge) {
			if(p != v) {
				ret[v] += ret[s] + 1;
				dfs(v, s, ret);
			}
		}
		return ret;
	}
}


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

struct edge{int to, cost;};

int N, M;
vector<edge> G[200001];
int dist[200001];

void Dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P> > que;
	fill(dist, dist + N, INF);

	dist[s] = 0;
	que.push(P(0, s));

	while(!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if(dist[v] < p.first) continue;
		for(int i = 0; i < G[v].size(); ++i) {
			edge e = G[v][i];
			if(dist[e.to] > dist[v] + e.cost) {
				dist[e.to] = dist[v] + e.cost;
				que.push(P(dist[e.to], e.to));
			}
		}
	}
}

int main() {
	scanf("%d %d", &N, &M);
	rep(i, M) {
		int a, b;
		scanf("%d %d", &a, &b);
		--a; --b;
		G[a].push_back((edge){b, 1});
		G[b].push_back((edge){a, 1});
	}
	Dijkstra(0);
	if(dist[N - 1] == 2) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 15080
#include <bits/stdc++.h>
using namespace std;
int main() {

int a;
   cin >> a;
   if(1<=a/100&&a/100<=12){
if(1<=a%100&&a%100<=12){
cout <<"AMBIGUOUS" <<endl;
}
else{
  cout <<"MMYY" << endl;
    }
}
  else{
if(1<=a%100&&a%100<=12){
  cout << "YYMM" << endl;
}
else {
  cout << "NA"<< endl;
}
  }

}


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


maxcount = 0
count = 0
for i in range(n-1):
    if hs[i+1] - hs[i] == 0:
        count += 1
    elif hs[i+1] - hs[i] < 0:
        count += 1
    else:
        if count >= maxcount:
            maxcount = count
        count = 0


print(max(count, maxcount))


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

int main(){
  int height;
  int width;
  while(true){
    cin >> height >> width;
    if(height == 0 && width == 0)
      break;
    for (int i = 0; i < height; i++){
      for (int j = 0; j < width; j++){
        if ((i + j) % 2 == 0){
          cout << "#";
        }
        else {
          cout << ".";
        }
      }
      cout << "\n";
    }
    cout << "\n";
  }
  return 0;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int main(){
    string str; cin >> str;
    stack<char> sta;
    for(int a = 0;a < str.size();a++){
        if(str.at(a)=='S'){
            sta.push(str.at(a));
        }else
        if(str.at(a)=='T'&&sta.empty()){
            sta.push(str.at(a));
        }else
        if(str.at(a)=='T'&&sta.top()=='T'){
            sta.push(str.at(a));
        }else if(str.at(a)=='T'&&sta.top()=='S'){
            sta.pop();
        }
    }
    COUT(sta.size());
    return 0;
}


Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
int a[55],b[55];
int n,m;
bool graph[55][55];
bool visited[55];
void dfs(int v)
{
	visited[v]=true;
	for(int v2=0;v2<n;v2++)
	{
		if(!graph[v][v2])continue;
		if(visited[v2])continue;
		dfs(v2);
	}
}
int main(void)
{
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
		a[i]--,b[i]--;
		graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
	}
	int ans=0;
	for(int i=0;i<m;i++)
	{
		graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
		for(int j=0;j<n;j++)
		visited[j]=false;
		dfs(0);
		bool bridge=false;
		for(int j=0;j<n;j++)
		if(visited[j]==false)bridge=true;
		if(bridge)ans++;
		graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(int i = (a); i<(b); ++i)
#define rep(i, n) for (int i=0; i<(n); ++i)
#define out(x) cout << x << endl

int main() {
    ll N;
    cin >> N;
    ll m=sqrt(N);
    for(ll i=m; i>0; i--){
        if(N%i == 0){
            out(i+(N/i)-2);
            return 0;
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
            long a = sc.nextLong();
            long b = sc.nextLong();
            long c = a - b;
            long gcd;
            if (c < 0){
                gcd = gcd(b, a);
            } else {
                gcd = gcd(a, b);
            }
            long lcm = a * b / gcd;
         System.out.println(gcd + " " + lcm);
        }
    }

    public static long gcd(long a, long b){
        long c = a % b;
        if (c == 0 ){
            return b;
        } else {
           return gcd(b, c);
        }
    }
}



Measured memory_bytes: 26128
//package cp;
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
	BigInteger bi1=new BigInteger("2");//initialize as string
//	1.BigInteger bi=new BigInteger(Readers.next());- take input as biginteger
	StringBuilder sb=new StringBuilder();
//	2.StringBuilder temp=new StringBuilder(str[i-1]);
//	3.String rev=temp.reverse().toString(); convert sb to string
//	4.if(str[i].compareTo(rev)>=0)minn=0;-compare two Strings
//  5.(Initialize as string) - (a.add(b)) - (array initialized with null and not 0)
	Integer[] ARRE=new Integer[5];//Integer sort-TLE-Initialize object elements i.e a[0].
	static final int mod1 = 1000000007;//or 1e9+7
//	6.System.exit(0); to exit from code....esp in recur 
	long gcd(long a,long b) {if(b==0)return a;else return gcd(b,a%b);}
	long ceil(double d) {return (long)Math.ceil(1.0*d);}
	int ch_int(char c) {return Integer.parseInt(String.valueOf(c));}//change char to Integer
	String ch_str(char c) {return String.valueOf(c);}
	String int_str(int num) {return Integer.toString(num);}
	void divisor(long n,int start) {
		int cnt=0;for(int i=start;i<=Math.sqrt(n);i++) {
		if(n%i==0) {if(i==n/i)cnt++;else cnt+=2;}}}
	public static void main(String[] args) throws IOException {	
		PrintWriter out = new PrintWriter(System.out);
		Readers.init(System.in);
		Main obj=new Main();
		String s=Readers.next();
		int cnt=0;
		if(s.charAt(0)=='S');
		else cnt++;
		int maxx=cnt;
		for (int i = 1; i <s.length(); i++) {
			if(s.charAt(i)==s.charAt(i-1) && s.charAt(i)=='R') {
				cnt++;
			}
			else {
				if(s.charAt(i)=='R')cnt=1;
				else cnt=0;
			}
			maxx=Math.max(cnt, maxx);
		}
		System.out.println(maxx);
		out.flush();
	}
}
class Readers {
 
    static BufferedReader reader;
 
    static StringTokenizer tokenizer;
 
 
 
    /** call this method to initialize reader for InputStream */
 
    static void init(InputStream input) {
 
        reader = new BufferedReader(
 
                     new InputStreamReader(input) );
 
        tokenizer = new StringTokenizer("");
 
    }
 
 
 
    /** get next word */
 
    static String next() throws IOException {
 
        while ( ! tokenizer.hasMoreTokens() ) {
 
            //TODO add check for eof if necessary
 
            tokenizer = new StringTokenizer(
 
                   reader.readLine() );
 
        }
 
        return tokenizer.nextToken();
 
    }
 
 
 
    static int nextInt() throws IOException {
 
        return Integer.parseInt( next() );
 
    }
 
	
 
    static double nextDouble() throws IOException {
 
        return Double.parseDouble( next() );
 
    }
    
    
    static long nextLong() throws IOException{
    	
		return Long.parseLong(next());
	}
 
}


Measured memory_bytes: 33124
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
//    int T; cin >> T;
//    while(T--) 
//    {
    	int N;
    	cin>>N;
    	int ans=1000*(N/500);
        N%=500;
        ans+=5*(N/5);
        cout<<ans<<endl;
//    }
	
	return 0;
}
 


Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
LL s[SIZE];
int u[SIZE],tt;
int main(){
    int N; R(N);
    REP(i,N)R(s[i]);
    LL an=0;
    REPP(i,1,N-1){
        int ll=i,rr=N-1-i;
        LL now=0;
        tt++;
        while(ll<N-1&&u[ll]!=tt&&u[rr]!=tt&&ll!=rr&&rr>i){
            now+=s[ll]+s[rr];
            u[ll]=u[rr]=tt;
            ll+=i;
            rr-=i;
            an=max(an,now);
        }
    }
    W(an);
    return 0;
}


Measured memory_bytes: 4736
N = gets.to_i

Up = []
Down = []
N.times do
    m = 0
    c = 0
    gets.chomp.each_char do |s|
        c += s== "(" ? 1 : -1
        m = [c,m].min
    end

    if c >= 0 then
        Up << [m,c] 
    else
        Down << [m-c, -c]
    end
end 

a,b = [Up,Down].map do |list|
    curr = 0
    list.sort_by!{|m,f| - m}
    list.each do |m,f|
        if m+curr<0 then
            puts "No"
            exit
        end
        curr += f
    end
    curr
end

puts a==b ? "Yes" : "No"


Measured memory_bytes: 90908
#pragma GCC optimize(2)
#pragma GCC optimize(3)   
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < ll > vl;
typedef vector < vl > vvl;
typedef pair < ll, ll > pll;
typedef vector < pair < ll, ll > > vpll;
#define kill freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(c) c.begin(), c.end()
#define go(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)
#define back(c,it) for(auto it=(c).rbegin(); it!=(c).rend(); it++)
#define fi first
#define se second
#define MOD 998244353
#define Boost() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD1 1000000007
#define MOD3 999999937
ll power(ll a, ll b){ll res=1;a=a%MOD1;while(b>0){if(b&1){res=(res*a)%MOD1;}a=(a*a)%MOD1;b>>=1;}return res;}
ll fermat_inv(ll y){return power(y,MOD1-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
#define oo INT_MAX
const ll N = 2e5;
vl adj[N];
ll n;
ll ans = 0;
void dfs(ll s = 0,ll p = -1){
    for(auto x:adj[s]){
        if(x!=p)dfs(x,s);
    }
    if(s==0)ans+=n;
    else{
        if(s>p){
            ans+=((s-p)*(n-s));
        }else{
            ans+=((s+1)*(p-s));
        }
    }
}
void solve(){
    cin>>n;
    fo(i,n-1){
        ll x,y;
        cin>>x>>y;
        x--;y--;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    dfs();
    cout<<ans;
}
int main(){
    Boost();
    #ifndef ONLINE_JUDGE 
    kill
    #endif
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}
 
 
 
 
 


Measured memory_bytes: 23968
N = int(input())
T = [int(input()) for k in range(N)]
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

# aとbの最小公倍数
# a*b = lcm(a,b)*gcd(a,b) より
def lcm(a,b):
    return a*b//gcd(a,b)
ans = 1
for e in T:
    ans = lcm(e,ans)
print(ans)


Measured memory_bytes: 38756
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;


int main()
{
	int a, over=0;
	long long int total=1;
	cin >> a;
	for(int k=0; k<a; k++)
	{
		long long int b;
		cin >> b;
		if(b != 0 && total > 1000000000000000000ll/b)
		{
			over++;
		}
		else if(b == 0)
		{
			cout << 0;
			return 0;
		}
		else
		{
			total *= b;
		}	
	}
	if(over > 0)
	{
		cout << -1;
	}
	else
	{
		cout << total;	
	}
}



Measured memory_bytes: 3636
//abc110_d.cpp
//Wed May  1 09:55:15 2019

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;
ll mod = 1000000007;
int n;

long dp[100100][32];

long nCr(int n, int r)
{
	if(n==r) return dp[n][r] = 1;
	if(r==0) return dp[n][r] = 1;
	if(r==1) return dp[n][r] = n;
	if(dp[n][r]) return dp[n][r];
	return dp[n][r] = (nCr(n-1,r) + nCr(n-1,r-1))%mod;
}

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

	map<int,int> num;
	int a = 2;
	int temp = m;
	while (temp>=a*a){
		if (temp%a == 0){
			auto itr = num.find(a);
			if (itr == num.end()){
				num[a] = 1;
			}else{
				num[a]++;
			}
			temp = temp/a;
		}else {
			a++;
		}
	}
	if (temp!=1){
		auto itr = num.find(temp);
		if (itr == num.end()){
			num[temp] = 1;
		}else{
			num[temp]++;
		}
	}

	ll ans = 1;
	for (auto itr = num.begin();itr!=num.end();itr++){
//		cout << itr->first << " " << itr->second<<endl;
		ll temp = nCr(itr->second+n-1,itr->second);
		ans = (ans * temp)%mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 29952
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> v;
  rep(i,H){
    string s;
    cin >> s;
    v.push_back(s);
  }

  vector<vector<int>> ret(H, vector<int>(W, 0));
  int id = 1;
  rep(i,H){
    int num = 0;
    rep(j,W) if(v[i][j] == '#') num++;

    if(num == 0) continue;
    rep(j,W){
      if(v[i][j] == '.') ret[i][j] = id;
      else {
        ret[i][j] = id;
        id++;
      }
    }
    if(v[i][W-1] != '#'){
      for(int j=W-1; j>=0; j--) if(ret[i][j] == id) ret[i][j] = id-1;
    }
  }


  rep(i,H){
    if(ret[i][0] == 0){
      int hh = -1;
      REP(ii,i+1,H){
        if(ret[ii][0] != 0){
          hh = ii;
          break;
        }
      }
      if(hh == -1){
        for(int ii=i-1; ii>=0; i--){
          if(ret[ii][0] != 0){
            hh = ii;
            break;
          }
        }
      }
      rep(j,W){
        ret[i][j] = ret[hh][j];
      }
    }
  }


  
  rep(i,H){
    rep(j,W){
      if(j>0) cout << " ";
      cout << ret[i][j];
    }
    cout << endl;
  }
  
  return 0;
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  cout << fixed << setprecision(15);
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a (n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    --a[i];
  }
  vector<int> occ (n, -1);
  vector<int> path;
  int cur = 0;
  while (occ[cur] == -1) {
    occ[cur] = (int)path.size();
    path.push_back(cur);
    cur = a[cur];
  }
  if (k < path.size()) {
    cout << path[k] + 1 << '\n';
  } else {
    int idx = occ[cur];
    ll len = path.size() - idx;
    k -= idx;
    cout << path[k%len+idx] + 1 << '\n';
  }
  return 0;
}



Measured memory_bytes: 5840
#include <stdio.h>

int a[200001], b[200001];

int Abs(int a){
  if(a < 0) a *= -1;
  return a;
}

void Do(int N){
  int i, j, M, S;
  M = 0;
  for(i = 1;i <= N;i++) scanf("%d", &a[i]);
  for(i = N;i >= 1;i--){
    if(i > (double) N / 2){
      b[i] = a[i];
      if(b[i] == 1) M++;
    }else{
      S = 0;
      for(j = i * 2;j <= N;j += i) S += b[j];
      b[i] = Abs(S % 2 - a[i]);
      if(b[i] == 1) M++;
    }
  }
  printf("%d\n", M);
  for(i = 1;i <= N;i++){
    if(M == 1 && b[i] == 1) printf("%d\n", i);
    else if(b[i] == 1){
      printf("%d ", i);
      M--;
    }
  }
}

int main(void){
  int N;
  scanf("%d", &N);
  Do(N);
  return 0;
}


Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		sc.close();
	
		//出力
		String ans=null;
		if (a.length() > b.length() ){
			ans = "GREATER";
		}else if( a.length() < b.length() ){				
			ans = "LESS";
		}else{
			for(int i=0; i<a.length(); i++){
				int da = a.charAt(i);
				int db = b.charAt(i);
				if(da>db){
					ans = "GREATER";
					break;
				}else if(db>da){
					ans = "LESS";
					break;
				}
			}				
			if(ans==null){
				ans = "EQUAL";
			}
		}
		
		System.out.println(ans);

	}

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;bool t = true;cin >> a >> b >> c >> d;
  while(a > 0 && c > 0){
    if(t) c -= b;
    else a -= d;
    t ^= 1;
  }
  cout << ((a > 0) ? "Yes":"No") << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

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

        String S = sc.next();

        if (S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;


int main(){
	string s;
  	cin >> s;
	cout << ((s=="AAA" || s == "BBB") ? "No" : "Yes") << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
vector<string> parse(const string &s) {
  vector<string> ret;
  string buf;
  REP(i,s.size()) {
    if(s[i] == 'u') {
      ret.push_back(buf);
      buf.clear();
    }
    else {
      buf += s[i];
    }
  }
  return ret;
}
vector<pair<int, int>> toStates(const vector<string> &ops) {
  vector<pair<int, int>> states;
  for(const string &op : ops) {
    // DEBUG(op);
    int locked = 0;
    for(char c : op) {
      states.emplace_back(locked, c - '0');
      locked |= (1 << (c - '0'));
    }
  }
  return states;
}
bool contains(int A, int B) {
  // A contains B
  while(B > 0) {
    if(B & 1) {
      if((A & 1) == 0) return false;
    }
    A >>= 1;
    B >>= 1;
  }
  return true;
}
bool dp[1 << 10][10];
signed main() {
  ios::sync_with_stdio(false);
  while(true) {
    int N; cin >> N;
    if(N == 0) break;
    string T; cin >> T;
    vector<string> ops = parse(T);
    vector<pair<int, int>> states = toStates(ops);
    memset(dp, 0, sizeof(dp));
    bool unsafe = false;
    queue<pair<int, int>> que;
    for(const auto &p : states) {
      if((p.first >> p.second) & 1) unsafe = true;
      que.emplace(p);
      dp[p.first][p.second] = true;
    }
    while(!que.empty()) {
      auto p = que.front(); que.pop();
      for(int S = 0; S < (1 << 10); ++S) {
        for(int next = 0; next < 10; ++next) {
          if(dp[S][next] == false) continue;
          auto q = make_pair(S, next);
          if((p.first & q.first) != 0) continue;
          if((p.first >> q.second) & 1 && dp[p.first | q.first][p.second] == false) {
            dp[p.first | q.first][p.second] = true;
            que.emplace(p.first | q.first, p.second);
          }
          if((q.first >> p.second) & 1 && dp[p.first | q.first][q.second] == false) {
            dp[p.first | q.first][q.second] = true;
            que.emplace(p.first | q.first, q.second);
          }
        }
      }
    }
    REP(S1,1<<10) {
      REP(n1,10) {
        if(dp[S1][n1] == false) continue;
#if 0
        if(dp[S1][n1]) {
          cerr << "[";
          REP(i,10) {
            if((S1 >> i) & 1) cerr << i;
          }
          cerr << "] " << n1 << endl;
        }
#endif
        REP(S2,1<<10) {
          REP(n2,10) {
            if((S1 & S2) == 0 && dp[S1][n1] && dp[S2][n2]) {
              if((S1 >> n2) & 1 && (S2 >> n1) & 1) {
                unsafe = true;
              }
            }
          }
        }
      }
    }
    cout << (unsafe ? "UNSAFE" : "SAFE") << endl;
  }
}

Measured memory_bytes: 3616
x,n=map(int, input().split())
p = list(map(int, input().split()))
p=sorted(p)
last=1000
zettai=1000
for i in range(0, 102):
    if i not in p:
        if zettai>abs(i-x):
            zettai=abs(i-x)
            last=i
print(last)


Measured memory_bytes: 61968
#include<bits/stdc++.h>
#define N (1800009)
#define LL long long
#define MOD (1000000007)
using namespace std;

LL inv[N],fac[N],facinv[N];
LL n,m,k,ans,f[N];

void Init()
{
	fac[0]=facinv[0]=inv[1]=1;
	for (int i=1; i<=1800000; ++i)
	{
		if (i!=1) inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
		fac[i]=fac[i-1]*i%MOD; facinv[i]=facinv[i-1]*inv[i]%MOD;
	}
}

LL C(LL n,LL m)
{
	if (n<m) return 0;
	return fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;
}

LL Qpow(LL a,LL b)
{
	LL ans=1;
	while (b)
	{
		if (b&1) ans=ans*a%MOD;
		a=a*a%MOD; b>>=1;
	}
	return ans;
}

int main()
{
	Init();
	cin>>n>>m>>k;
	f[0]=1; f[1]=2;
	for (int i=1; i<=m+k; ++i)
		f[i]=(f[i-1]*2-C(i-1,m)-C(i-1,k))%MOD;
	(ans+=Qpow(3,m+k))%=MOD;
	for (int i=n+1; i<=n+m+k; ++i)
		(ans+=f[i-n]*C(i-1,n-1)%MOD*Qpow(3,n+m+k-i)%MOD)%=MOD;
	cout<<(ans+MOD)%MOD<<endl;
}

Measured memory_bytes: 50304
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		new ABC049B().solve();
	}
}

class ABC049B {
	void solve() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String hw = br.readLine();
		int h = Integer.parseInt(hw.split(" ")[0]);
		int w = Integer.parseInt(hw.split(" ")[1]);
		String[] c = new String[h];
		for (int i=0; i < h; i++) {
			c[i] = br.readLine();
		}
		for (int i=0; i < c.length; i++) {
			System.out.println(c[i]);
			System.out.println(c[i]);
		}
	}
}

class ABC049A {
	void solve() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String yes = "vowel";
		String no = "consonant";
		if (br.readLine().matches("a|e|i|o|u")) System.out.println(yes);
		else System.out.println(no);
	}
}


Measured memory_bytes: 9356
import math
INF = 10000000000000000000000000000000000
N, K = map(int, input().split())
points = []
to_search_x = []
to_search_y = []
points_matrix = [[0]*(N+1) for i in range(N+1)]
for i in range(N):
    xi, yi = map(int, input().split())
    points.append([xi, yi])
    to_search_x.append(xi)
    to_search_y.append(yi)

to_search_x.sort()
to_search_y.sort()

def count(xmin, xmax, ymin, ymax):
    num = 0
    for i in range(N):
        x,y = points[i]
        if (xmin <= x and xmax >= x) and (ymin <= y and ymax >= y):
            num += 1
    return num

for n in range(N):
    for i in range(N):
        for j in range(N):
            if points[n][0] <= to_search_x[i] and points[n][1] <= to_search_y[j]:
                points_matrix[i+1][j+1] += 1

ans = INF
for i in range(N):
    for j in range(i,N):
        for k in range(N):
            for l in range(k,N):
                if (points_matrix[i][k] + points_matrix[j+1][l+1] - points_matrix[i][l+1] - points_matrix[j+1][k]) >= K:
                    ans = min(ans, (to_search_x[j]-to_search_x[i])*(to_search_y[l]-to_search_y[k]))

print(ans)

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N; cin >> N;
    string S; cin >> S;
    int x = 0, ans=0;
    for(char c : S){
        if(c == 'D') x--;
        else x++;
        chmax(ans,x);
    }
    cout << ans << en;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  char s[h][w];
  bool can_draw[h][w],tb,ans=true;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s[i][j];
      can_draw[i][j]=false;
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      tb=false;
      if(can_draw[i][j]==true) continue;
      if(s[i][j]=='#'){
        if(i!=0){
          if(s[i-1][j]=='#'){
            tb=true;
          }
        }
        if(j!=0){
          if(s[i][j-1]=='#'){
            tb=true;
          }
        }
        if(i!=h-1){
          if(s[i+1][j]=='#'){
            tb=true;
          }
        }
        if(j!=w-1){
          if(s[i][j+1]=='#'){
            tb=true;
          }
        }
        can_draw[i][j]=tb;
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='#'&&can_draw[i][j]==false){
        ans = false;
        break;
      }
    }
    if(ans==false)break;
  }
  if(ans) cout << "Yes\n";
  else cout <<"No\n";

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define REP(i,m,n) for (int i=m;i<n;i++)
#define FOR(i,m,n,a) for(int i=m;i<n;i+=a)
const ll MOD=1e9+7;

int main(){
  int N;
  ll a=1;
  cin >> N;
  REP(i,0,N){
    a = (a*(i+1))%MOD;
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a = 10000, b = 5000, c = 1000;
    int n, y;
    bool flag = false;
    cin >> n >> y;
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j + i <= n; j++)
        {
            int rem = y - (i * 10000 + j * 5000);
            if (rem >= 0 && rem / 1000 + i + j == n)
            {
                flag = true;
                cout << i << " " << j << " " << rem / 1000 << endl;
                break;
            }
        }
        if (flag)
            break;
    }
    if (!flag)
        cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define ll long long
int n,a,b=9999999;
int fx[200030],fy[200020];
char s[200020];
int main(){
	scanf("%d",&n);
	scanf("%s",s);
	int l=strlen(s);
	for(int i=1;i<l;i++){
		if(s[i-1]=='#') fx[i]=fx[i-1]+1;
		else fx[i]=fx[i-1];
	}
	for(int i=l-2;i>=0;i--){
		if(s[i+1]=='.') fy[i]=fy[i+1]+1;
		else fy[i]=fy[i+1];
	}
	for(int i=0;i<l;i++){
		b=min(fx[i]+fy[i],b);
	}
	cout<<b;
	return 0;
}

Measured memory_bytes: 2552
#include<iostream>
using namespace std;
int main()
{
  int n;
  long long sum=0;
  cin >> n;
  for(int i=1;i<n+1;i++)
  {
    if(i%3 !=0 && i%5!= 0)
      sum+= i;
  }
  cout << sum;
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

template<typename T>
struct BIT{
    int N;
    vector<T> dat;
    BIT(int n) : N(n), dat(n+1,0){ }
    void add(int i, T num){
        for(int x = i+1; x <= N; x += (x & -x)) dat[x] = (dat[x] + num) % mod;
    }
    T sum(int i){
        T ret = 0;
        for(int x = i+1; x > 0; x -= (x & -x)) ret = (ret + dat[x]) % mod;
        return ret;
    }
    T sum(int i, int j){
        return (sum(j) + mod - sum(i-1)) % mod;
    }
};


int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    int n; cin >> n;
    string s; cin >> s;
    vvl dp(n+1, vl(n));
    debug(s)

    rep(i,n) dp[0][i] = 1;
    rep(i,n-1){
        BIT<ll> bit(n);
        rep(j,n-i) bit.add(j, dp[i][j]);
        rep(j,n-i-1){
            if(s[i] == '<') dp[i+1][j] = bit.sum(0, j);
            if(s[i] == '>') dp[i+1][j] = bit.sum(j+1, n-1);
        }
    }
    cout << dp[n-1][0] << endl;
    return 0;
}

Measured memory_bytes: 70784
#include <stdio.h>
#include <algorithm>

using namespace std;

int H;

void maxHeapify(long long array[],int i){
	int left = 2*i;
	int right = 2*i + 1;
	if(left > H) return;
	int largest = i;
	if(right <= H){
		if((array[right] > array[left]) && (array[right] > array[i])){
			largest = right;
		}else if((array[left] > array[right]) && (array[left] > array[i])){
			largest = left;
		}
	}else{
		if(array[i] < array[left]){
			largest = left;
		}
	}
	if(largest != i){
		swap(array[i],array[largest]);
		maxHeapify(array, largest);
	}
}

void buildMaxHeap(long long array[]){
	for(int i = H/2; i >=1; i--) maxHeapify(array,i);
}

int main(){
	scanf("%d",&H);
	long long array[H+1];

	for(int i = 1; i <= H; i++) scanf("%lld",&array[i]);

	buildMaxHeap(array);

	for(int i = 1; i <= H; i++) printf(" %lld",array[i]);
	printf("\n");
}



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

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

using namespace std;
typedef long long ll;

bool prime[10000000];
void Eratosthenes(int n) {
    rep(i,n) prime[i] = true;
    prime[0] = false;
    prime[1] = false;

    REP(i,2,(int)sqrt(n)) {
        if(prime[i]) {
            for(int j=0;i*(j+2)<n;j++) {
                prime[i*(j+2)] = 0;
            }
        }
    }
}

int main() {
    Eratosthenes(10000000);

    int n;
    while(cin >> n && n) {
        int ans = 0;

        REP(i,n+1,1299710) {
            if(prime[i]) {
                ans = i;
                break;
            }
        }

        for(int i=n-1;i>=2;i--) {
            if(prime[i]) {
                ans -= i;
                break;
            }
        }

        if(prime[n]) cout << 0 << endl;
        else cout << ans << endl;

    }

    return 0;
}

Measured memory_bytes: 10924
#include<iostream>
#include<algorithm>
using namespace std;
 
int main() {
	long long int n, b, c,bc,cc,q = 0;
	long long int count = 0;

	cin >> n >> b >> c;
	bc = n / (b + c);
	cc = n % (b + c);
	if (cc>b) {
		cc = b;
	}
	q = bc * b;
	count = q+cc;
	if (b == 0) {
		count = 0;
	}
	cout << count << endl;
}


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

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vl> vvvl;
typedef double T;
typedef vector<T> vt;
typedef vector<vt> vvt;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpi;
typedef tuple<ll, int, int> tlii;

const int MOD = 1e9+7; // 998244353;
const int INF = 1e9+1;

using Cost = int;
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n;
  cin >> k;
  vector<Cost> costs(n);
  for (int i = 0; i < n; ++i) {
    cin >> costs[i];
  }
  vector<int> dp(n, INF);
  dp[0] = 0;
  dp[1] = abs(costs[1] - costs[0]);

  for (int i = 2; i < n; ++i) { 
    dp[i] = min(dp[i - 1] + abs(costs[i] - costs[i - 1]),
                dp[i - 2] + abs(costs[i] - costs[i - 2]));
    int foo = INF;
    for (int j = 1; j <= k && j <= i; ++j) {
      foo = min(foo, dp[i - j] + abs(costs[i] - costs[i - j]));
    }
    dp[i] = foo;
  }
  cout << dp.back() << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;

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

	char c = 'A';
	int count = 0;;

	for (int i = 0; i < S.size(); i++)
	{
		if (c != S[i]) {
			c = S[i];
			count++;
		}
	}
	printf("%d\n", count - 1);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
   char C;
   cin >> C;
   cout << (char)(C+1) << endl; 
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a,b,c;

	scanf ("%d %d %d",&a,&b,&c);
	for (int s=-1000;s<=1000;s++){
		int p[3][3];
		p[0][0] = a;
		p[0][1] = b;
		p[1][1] = c;
		p[0][2] = s - a - b;
		p[2][0] = s - c - p[0][2];
		p[1][0] = s - a - p[2][0];
		p[1][2] = s - c - p[1][0];
		p[2][1] = s - b - c;
		p[2][2] = s - a - c;

		bool good = 1;
		for (int i=0;i<3;i++) if (p[i][0] + p[i][1] + p[i][2] != s) good = 0;
		for (int i=0;i<3;i++) if (p[0][i] + p[1][i] + p[2][i] != s) good = 0;
		if (p[0][0] + p[1][1] + p[2][2] != s) good = 0;
		if (p[2][0] + p[1][1] + p[0][2] != s) good = 0;
		if (good){
			for (int i=0;i<3;i++) for (int j=0;j<3;j++) printf ("%d%c",p[i][j],j+1<3?' ':'\n');
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);


int N,M,Q;
vector<vector<int>> A(0);

void make(vector<int> a,int n)
{
  if(n==N) {A.push_back(a); return;}
  int l=a.at(n-1);
  for(int i=l;i<=M;i++)
  {
    auto b=a;
    b.push_back(i);
    make(b,n+1);
  }
}  



int main() 
{
  cin>>N>>M>>Q;
  rep(i,M)
  {
    make({i+1},1);
  }  
  /*
  for(auto a:A)
  {
    for(auto w:a)
    {
      cout<<w<<" ";
    }
    cout<<endl;
  }
  */
  
  vector<int> a(Q);
  vector<int> b(Q);
  vector<int> c(Q);
  vector<int> d(Q);
  rep(i,Q)
  {
    cin>>a.at(i)>>b.at(i)>>c.at(i)>>d.at(i);
    a.at(i)--;
    b.at(i)--;
  }
  
  int ans=0;
  for(auto hoge:A)
  {
    int sum=0;
    rep(i,Q)
    {
      if(hoge.at(b.at(i))-hoge.at(a.at(i))==c.at(i))
      {
        sum+=d.at(i);
      }
    }
    ans=max(sum,ans);
  }
  
  cout<<ans<<endl;
  
  return 0;
}



Measured memory_bytes: 13516