akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define flash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define all(v) (v).begin(),(v).end() 
#define endl "\n"
#define int long long int
#define ll long long
#define ld long double
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
const int mod = 1000000007;
const int N=200005;
const int inf=1e18;
vector<vector<int>>adj(N);

bool isprime(int n){for(int i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
int factorial(int n){return (n==1 || n==0) ? 1:n*factorial(n-1);} 
int gcd(int a,int b){if (a==0)return b;return gcd(b%a,a);}
int lcm(int a,int b){return (a/gcd(a,b)*b);}
int max(int a,int b){int sol=a>b?a:b;return sol;}
int min(int a,int b){int sol=a<b?a:b;return sol;} 

void fun(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}


signed main(){
    flash;
    fun();
    int t=1;
    //cin>>t;
    while(t--){
        int a,b;
        cin>>a>>b;
        string s=to_string(a)+to_string(b);
        int k=stoi(s);
        int x=sqrt(k);
        if(x*x==k)
            Yes();
        else    
            No();
    }
    return 0;
}

Measured memory_bytes: 7812
#include<cstdio>
int main()
{
	int n,a,b,ans=0;scanf("%d%d%d",&n,&a,&b);
	for(int i=1;i<=n;i++)
	{
		int s=0,x=i;
		while(x) {s+=x%10;x/=10;}
		if(s>=a&&s<=b) ans+=i;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    ll n,a,b;
    ll ans;
    cin >> n >> a >> b;
    if(abs(a-b) % 2 ==0){
        ans = abs(a-b)/2;
    }
    else{
        ans =min(a-1,n-b) + 1 + (b-a-1)/2;
    }
    cout << ans << endl;
}

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

bool compare(pair<pair<string, int>, int> a, pair<pair<string, int>, int> b) {
    if (a.first.first != b.first.first) {
        return a.first.first < b.first.first;
    }
    else {
        return a.first.second > b.first.second;
    }
}

int main() {

    int N;
    cin >> N;

    vector<pair<pair<string, int>, int>> res;
    string S;
    int P;
    for (int i = 0; i < N; i++) {
        cin >> S >> P;
        res.push_back(make_pair(make_pair(S, P), i+1));
    }

    sort(res.begin(), res.end(), compare);

    for (int i = 0; i < N; i++) {
        cout << res[i].second << endl;
    }

    return 0;
}


Measured memory_bytes: 256
i=1
while True:
    x=int(input())
    if x==0:
        break
    x=1000-x
    a=x//500
    b=(x%500)//100
    c=(x%100)//50
    d=(x%50)//10
    e=(x%10)//5
    f=x%5
    print(a+b+c+d+e+f)
    i+=1


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

using namespace std;

int n , m , a[500][500] , del[500] , cnt[500] , p[500] , ans  =INT_MAX;

int main()
{
    scanf("%d%d",&n,&m);
    for(int i = 1; i<=n ; i++)
        for(int j = 1;  j<=m ; j++)
            scanf("%d",&a[i][j]);
    for(int i = 1;  i<=n ; i++)p[i] = 1;
    for(int t = 1 ; t<=m ; t++)
    {
        memset(cnt , 0 , sizeof(cnt));
        for(int i = 1 ; i <= n ; i++)
            while(p[i] <= m && del[a[i][p[i]]]) p[i]++;
        for(int i = 1 ; i<=n ; i++)
            cnt[a[i][p[i]]]++;
        int maxv = 0 , val = 0;
        for(int i = 1 ; i<=m ; i++)
        {
            if(cnt[i] > maxv && !del[i])
            {
                maxv = cnt[i];
                val = i;
            }
        }
        del[val] = 1;
        ans = min(ans , maxv);
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 896
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    cin>>n;
	cout<<n+n*n+n*n*n;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10596
import scala.collection.mutable.ListBuffer
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().trim.toInt
  var root: Node = _
  val buff = ListBuffer.empty[String]
  case class Node(var key: Int, var parent: Node, var left: Node, var right: Node){
    private def getDefaultKey(p: Node) = if(p == null) -1 else p.key
    override def toString: String = s"Node($key, ${getDefaultKey(parent)} ${getDefaultKey(left)} ${getDefaultKey(right)})"
  }
  
  (0 until n).foreach { _ =>
    val command = StdIn.readLine()
    command.split(' ') match {
      case Array("insert", key) => insert(Node(key.toInt, null, null, null))
      case Array("find"  , key) => 
        buff += (if(find(root, key.toInt) == null) f"no%n" else f"yes%n")
      case Array("delete"  , key) => 
        //println(key.toInt)
        val target = find(root, key.toInt)
        if(target != null) delete(target)
      case _ => 
        // print
        inorder(root)
        buff += f"%n"
        preorder(root)
        buff += f"%n"
    }
  }
  
  
  def insert(z: Node): Unit = {
    var y:Node = null
    var x:Node = root
    while(x != null){
      y = x
      if(z.key < x.key){
        x = x.left
      } else {
        x = x.right
      }
    }
    z.parent = y
    
    if(y == null){
      root = z
    } else if(z.key < y.key){
      y.left = z
    } else {
      y.right = z
    }
  }
  
  def preorder(n: Node): Unit = {
    buff += " " + n.key
    if(n.left != null) preorder(n.left)
    if(n.right != null) preorder(n.right)
  }

  def inorder(n: Node): Unit = {
    if(n.left != null) inorder(n.left)
    buff += " " + n.key
    if(n.right != null) inorder(n.right)
  }
  
  def find(x: Node, key: Int): Node = {
    var temp = x
    while(temp != null && key != temp.key){
      if(key < temp.key){
        temp = temp.left
      } else {
        temp = temp.right
      }
    }
    temp
  }

  def delete(z: Node): Unit = {
    var temp = if(z.left == null || z.right == null) z else {
      getSuccessor(z)
    }
    
    var x = if(temp.left != null){
      temp.left
    } else {
      temp.right
    }
    
    if(x != null){
      x.parent = temp.parent
    }
    
    if(temp.parent == null) {
      root = x
    } else {
      if(temp == temp.parent.left){
        temp.parent.left = x
      } else {
        temp.parent.right = x
      }
    }
    
    if(temp != z){
      z.key = temp.key
    }

  }
  
  def getSuccessor(x: Node): Node = {
    if(x.right != null){
      minimum(x.right)
    } else {
      var temp1 = x
      var temp2 = x.parent
      while(temp2 != null && temp1 == temp2.right){
        temp1 = temp2
        temp2 = temp2.parent
      }
      temp2
    }
    
  }
  
  def minimum(x: Node): Node = {
    var temp = x
    while(temp.left != null){
      temp = temp.left
    }
    temp
  }

  print(buff.mkString(""))
}




Measured memory_bytes: 545628
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>

using namespace std;
 
typedef long long ll;
const int N = 1e5+10;
const ll Maxn = 1e16;
const int MOD = 1e9 + 7;

int main(){
	string a;
	cin >> a;
	int f = 1;
	int sum = 'a' + 'b' + 'c';
	for(int i = 0; i < 3; i++){
		f += a[i];
	}
//	printf("%d %d \n", f - 1, sum);
	if(sum == f -1 )
		printf("Yes\n");
	else
		printf("No\n");
}

			

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var N string
	fmt.Scan(&N)

	A, _ := strconv.Atoi(string(N[0]))
	B, _ := strconv.Atoi(string(N[1]))
	C, _ := strconv.Atoi(string(N[2]))
	D, _ := strconv.Atoi(string(N[3]))

	if A+B+C+D == 7 {
		fmt.Printf("%d+%d+%d+%d=7\n", A, B, C, D)
	} else if A+B+C-D == 7 {
		fmt.Printf("%d+%d+%d-%d=7\n", A, B, C, D)
	} else if A+B-C+D == 7 {
		fmt.Printf("%d+%d-%d+%d=7\n", A, B, C, D)
	} else if A+B-C-D == 7 {
		fmt.Printf("%d+%d-%d-%d=7\n", A, B, C, D)
	} else if A-B+C+D == 7 {
		fmt.Printf("%d-%d+%d+%d=7\n", A, B, C, D)
	} else if A-B+C-D == 7 {
		fmt.Printf("%d-%d+%d-%d=7\n", A, B, C, D)
	} else if A-B-C+D == 7 {
		fmt.Printf("%d-%d-%d+%d=7\n", A, B, C, D)
	} else if A-B-C-D == 7 {
		fmt.Printf("%d-%d-%d-%d=7\n", A, B, C, D)
	}
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (true) {
			int height = sc.nextInt();
			int width = sc.nextInt();
			if (height == 0 && width == 0) {
				break;
			}
			for (int i = 0; i < height; i++) {
				if (i == 0 || i == height - 1) {
					for (int j = 0; j < width; j++) {
						System.out.print("#");
					}
				} else {
					System.out.print("#");
					for (int j = 1; j < width - 1; j++) {
						System.out.print(".");
					}
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 37052
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			int n = Integer.parseInt(input.readLine());
			
			int taro = 0;
			int hanako = 0;
			for (int i = 0; i < n; i++) {
				final String[] cards = input.readLine().split(" ");
				if (0 < cards[0].compareTo(cards[1])) {
					taro += 3;
				} else if (cards[0].compareTo(cards[1]) < 0) {
					hanako += 3;
				} else if (cards[0].compareTo(cards[1]) == 0) {
					taro++;
					hanako++;
				}
			}
			
			System.out.println(taro + " " + hanako);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
}

Measured memory_bytes: 20288
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
//i64 mod = 1000000007;
i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

int main(int argc, char **argv) {
    i64 n, k;
    cin >> n >> k;

    i64 ans{0};

    vector<i64> a0(n+1), as(n+1, 0);
    for (i64 i=1;i <n+1; ++i) {
        cin >> a0[i];
        as[i]=as[i-1]+a0[i];
    }

    map<i64, i64> search;
    for (int i=0; i<n+1; ++i) {
        if (i-k >= 0) {
            i64 ik = (as[i-k]-(i-k)) % k;
            --search[ik];
        }

        i64 ai = (as[i]-i) % k;
        auto it = search.find(ai);
        if (it != search.end()) {
            ans += it->second;
            ++(it->second);
        } else {
            search[ai] = 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



int main(){
    ll n,m,a[201010],sum[201010]={};
    string s;
   cin>>n;
   rep(i,n-1){cin>>a[i];sum[a[i]]++;}
   rep(i,n){
       cout<<sum[i+1]<<endl;
   }
   //cout<<endl;
}


Measured memory_bytes: 6740
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;

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

  int limit = 1;
  for (int i = 0; i < N; i++) {
    limit *= 4;
  }

  int bestCost = 1000000;
  for (int i = 0; i < limit; i++) {
    vector<int> count(3);
    vector<int> len(3);
    int tempCost = 0;

    int n = i;
    int ct = 0;
    while (n > 0) {
      if (n % 4 > 0) {
        count[n % 4 - 1]++;
        len[n % 4 - 1] += l[ct];
        if (count[n % 4 - 1] > 1) {
          tempCost += 10;
        }
      }

      n /= 4;
      ct++;
    }

    tempCost += abs(len[0] - A) + abs(len[1] - B) + abs(len[2] - C);

    if (len[0] > 0 && len[1] > 0 && len[2] > 0 && tempCost < bestCost) {
      bestCost = tempCost;
    }
  }

  cout << bestCost << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();
		int[] arr = r.ria();
		int[] tolls = r.ria();
		int mid = Math.abs(Arrays.binarySearch(tolls, arr[2]))-1;
		if(mid > tolls.length/2) print(tolls.length-mid);
		else print(mid);
		
	}
	//a & b =1...k=1/2
	// k > a & b
	
	public static int getDigitSum(int n) {
		String str = ""+n;
		int sum = 0;
		for(int i = 0; i<str.length();i++) {
			sum += Integer.parseInt(""+str.charAt(i));
		}
		return sum;
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static void swap(int[] arr, int pos1, int pos2) {
		int temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	public static void swap(long[] arr, int pos1, int pos2) {
		long temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


Measured memory_bytes: 20308
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    string S;
    cin >> S;
    bool change,judge;
    judge = true;
    change = false;
    for(int i = a;i <= max(c,d);i++){
        if(S[i] == '#' && S[i+1] == '#'){
            judge = false;
        }
        if(c > d && i <= max(c,d)-2 && i <= min(c,d)-1 && b-1 <= i){
            if(S[i] == '.' && S[i+1] == '.' && S[i+2] == '.'){
                change = true;
            }
        }
        if(judge == false)break;
    }
    if(judge == false)cout << "No" << endl;
    else if(c > d && change == false)cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int i=0;
  string s,t;
  for(;cin >> s >> t,t!="X";){
  if(find(s.begin(),s.end(),'_')!=s.end()){
    if(t!="D"){
      for(i=0;i<s.length();i++)
        if(s[i]=='_'){
          if(s[i+1]=='_'||s[i+1]==0){cout << "Error!" << endl;return 0;}
          s.erase(i,1),s[i]-=0x20;
        }
      if(t=="U")s[0]-=0x20;
    }
    cout << s << endl;
  }else{
    if(between('A',s[0],'Z'))s[0]+=0x20;
    if(t=="U")s[0]-=0x20;
    if(t=="D")
      for(i=0;i<s.length();i++)
        if(between('A',s[i],'Z'))s.insert(i,1,'_'),s[++i]+=0x20;
    cout << s << endl;
  }
  }
}

Measured memory_bytes: 0
object Main extends App {
  import scala.math._
  
  val n = readInt
  val a = readLine.split(" ").map{_.toInt}
  
  //start != 0
  def solve(start:Int):Long = {
    var ans:Long = 0
    var sum:Long = start.toLong
    for (i <- 1 until n) {
      val presum = sum
      sum += a(i)
      if (sum == 0) {
        ans += 1
        sum = -presum/abs(presum)
      } else {
        val check = (presum/abs(presum))*(sum/abs(sum))
        if (check > 0) {
          ans += abs(sum)+1
          sum = -sum/abs(sum)
        }
      }
    }
    ans
  }
  
  if (a(0) == 0) println(min(solve(1),solve(-1))+1)
  else println(min(solve(a(0)),solve(-a(0)/abs(a(0)))+abs(a(0))+1))

}

Measured memory_bytes: 40172
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,tmp;
	scanf("%d%d",&a,&b);
	tmp=b/(a-1);
	if(b==1){
		cout<<0;
		return 0;
	}
	if(a==2){
		cout<<b-1;
		return 0;
	}
	if((a-1)*tmp+1>=b){
		cout<<tmp;
	}
	else cout<<tmp+1;
	return 0;
}


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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

//拡張ユークリッドの互除法
int extgcd(int a, int b, int &x, int &y) {
    int d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

// mod逆元
int mod_inverse(int a, int m) {
    int x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}

// 階乗、階乗逆元テーブル
int fact[1100000], fact_inv[1100000], inv[1100000];

int mod_fact(int n, int m) {
    fact[0] = fact_inv[0] = 1;
    inv[1] = 1;
    for (int i = 1; i <= n; i++) {
        fact[i] = fact[i - 1] * i % m;
        inv[i] = m - inv[m % i] * (m / i) % m;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % m;
    }
}

int N;
int A[110000], xt[110000];
int mod = 1e9 + 7;

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++)cin >> A[i];
    mod_fact(110000, mod);
    for (int i = 2; i < 110000; i++) {
        xt[i] = (xt[i - 1] + fact[N] * mod_inverse(i, mod) % mod) % mod;
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        (ans += (xt[i + 1] + xt[N - i] + fact[N]) * A[i] % mod) %= mod;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;
int main(){
	int a,b;
	std::cin >> a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)std::cout << "Possible" << std::endl;
	else std::cout << "Impossible" << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define sz(x) (ll)x.size()
#define lnt(s) (ll)s.length()
#define mt(cnt) cnt.empty()
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> osSet;

using pll = pair<ll, ll>;
using pl = pair<ll, pll>;
using tll = tuple<ll, ll, ll>;

const ll maxN = 1e5;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

ll func(ll x){
	return (x*(x+1))/2;
}

ll _pow(ll b, ll p){
	if(p == 0) return 1;
	if(p == 1) return b;
	ll exB = b*b;
	if(p&1) return b*_pow(exB, p/2);
	return _pow(exB, p/2);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	cout << t+s;
	return 0;
}

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

ll solve(int n, string const & s, int k) {
    ll cnt_dmc = 0;
    int cnt_m = 0;
    int cnt_c = 0;
    ll cnt_mc = 0;
    auto push = [&](int i) {
        if (s[i] == 'M') {
            cnt_m += 1;
        } else if (s[i] == 'C') {
            cnt_c += 1;
            cnt_mc += cnt_m;
        }
    };
    auto pop = [&](int i) {
        if (s[i] == 'D') {
            cnt_dmc += cnt_mc;
        } else if (s[i] == 'M') {
            cnt_m -= 1;
            cnt_mc -= cnt_c;
        } else if (s[i] == 'C') {
            cnt_c -= 1;
        }
    };
    REP (i, k) {
        push(i);
    }
    REP (i, n) {
        pop(i);
        if (i + k < n) push(i + k);
    }
    return cnt_dmc;
}

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int q; cin >> q;
    while (q --) {
        int k; cin >> k;
        cout << solve(n, s, k) << endl;
    }
    return 0;
}


Measured memory_bytes: 1412
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scn = new Scanner(System.in);
        String s = scn.next();
        String t = scn.next();
        int size = s.length();
        String tCut = t.substring(0, size);
        if (s.equals(tCut)){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35668
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* ---------- Functions */
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; }

map<int, int> prime_factor(int n) {
    map<int, int> ret;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }

    if (n != 1) ret[n] = 1;
    return move(ret);
};

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int N;
    cin >> N;
    auto m = prime_factor(N);
    int ret = 0;
    for (auto it = m.begin(); it != m.end(); it++) {
        int val = it->first;
        int num = it->second;
        int i = 1;

        while (num > 0) {
            if (num < i) break;
            ret++;
            num -= i;
            i++;
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3660
arg1,arg2 = map(int, input().split())
data = []
data2 = []
tmp = []
for x in range(0,arg1):
    tmp = input().split()
    data.append([int(tmp[i]) for i in range(arg2)])
for x in range(0,arg2):
    data2.append(int(input()))
for x in range(0,arg1):
    sum = 0
    for y in range(0,arg2):
        sum = sum + data[x][y] * data2[y]
    print(sum)


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

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

	int n, m;
	cin >> n >> m;

	vector<int> heights(n);

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

	vector<priority_queue<int>> graph(n);

	int a, b;
	for(int i = 0; i < m; i++){
		cin >> a >> b;
		--a;--b;
		graph[a].push(heights[b]);
		graph[b].push(heights[a]);
	}

	int ans = 0;
	for(int i = 0; i < n; i++){
		if(graph[i].size() == 0){
			++ans;
			continue;
		}
		if(heights[i] > graph[i].top()){
			++ans;
		}
	}

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

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

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var ret = new LinkedList<int>();
        var adL = true;
        for (int i = 0; i < n; i++)
        {
            if (adL) { ret.AddLast(a[i]);  adL = false; }
            else { ret.AddFirst(a[i]);  adL = true; }
        }
        var fin = ret.ToArray();
        if (!adL) Array.Reverse(fin);
        Console.WriteLine(string.Join(" ", fin));
    } 
}



Measured memory_bytes: 57620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int n;
    cin>>n;
    vector<long long int> v(n);
    long long int tmp;
    REP(i,n){
        cin>>tmp;
        v[tmp-1]=i;
    }
    REP(i,n-1){
        cout<<v[i]+1<<" ";
    }
    cout<<v[n-1]+1<<endl;

    return 0;
}


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

int main(){

  int i,j;
  char g[3][3];
  char win;
  
  while(1){
    
    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
	cin >> g[i][j];
	if(g[0][0]=='0') return 0;
	if(g[i][j]=='+') g[i][j]=(j+1)*(i+1);
      }
    }
  
    for(i=0;i<3;i++){
      if(g[i][0]==g[i][1] && g[i][0]==g[i][2]){
	win = g[i][0];
	break;
      }else if(g[0][i]==g[1][i] && g[0][i]==g[2][i]){
	win = g[0][i];
	break;
      }else if(g[0][0]==g[1][1] && g[0][0]==g[2][2]){
	win = g[0][0];
	break;
      }else if(g[0][2]==g[1][1] && g[0][2]==g[2][0]){
	win = g[0][2];
	break;
      }
      
    }
    
    if(i!=3) printf("%c\n",win);
    else puts("NA");

  }

    return 0;
} 

Measured memory_bytes: 1128
#include <iostream>
using namespace std;
int main(void){
    long long n,l=0,r;
    cin>>n;
    r=n;
    while(l+1<r){
        long long m=(l+r)/2;
        if(m*(m+1)/2<n){
            l=m;
        }else{
            r=m;
        }
    }
    l=r*(r+1)/2-n;
    for(int i=1;i<=r;i++){
        if(i!=l){
            cout<<i<<endl;
        }
    }
    
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

long long int dp[100000 + 10][2];

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

  std::vector<int> A(N);

  for (int i = 0; i < N; i++) {
    std::cin >> A[i];
  }

  for (int i = 0; i < N-1; i++) {
    // A[i]
    // -1 10 -100
  }

  // std::vector<int> AS(N+1);

  // for (int i = 1; i <= N; i++) {
  //   AS[i] += AS[i-1] + A[i-1];
  // }

  // int answer = std::accumulate(A.begin(), A.end(), 0);

  // for (int i = 0; i < N; i++) {
  //   // i <= x < j までの区間を反転する


  // }

  dp[0][0] = A[0];
  dp[0][1] = -A[0];

  for (int i = 1; i < N; i++) {
    dp[i][0] = std::max(dp[i][0], std::max(dp[i-1][0] + A[i], dp[i-1][1] - A[i]));
    dp[i][1] = std::max(dp[i][1], std::max(dp[i-1][1] + A[i], dp[i-1][0] - A[i]));
  }

  std::cout << dp[N-1][0] << std::endl;
}

// dp[i][s] = i番目をs(1 or -1)倍したときの最大値


Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main () {
    int n, m;
    int x[100000];

    cin >> n >> m;

    for (int i=0; i<m; i++) {
        scanf("%d", &x[i]);
    }
    if (n >= m) {
        cout << 0 << endl;
        return 0;
    }
    sort(x, x+m);

    int dist[100];
    for (int i=0; i<m-1; i++) {
        dist[i] = x[i+1] - x[i];
    }
    sort(dist, dist+(m-1));

    int ans = 0;
    for (int i=0; i<m-n; i++) {
        ans += abs(dist[i]);
    }

    cout << ans << endl;

    return 0;
}

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

	int a, b, c, k, i, ans = 0;
	
	scanf("%d %d %d %d", &a, &b, &c, &k);
	
	if(k < a)
		ans = k;
	if(k >= a){
		ans = a;
		k = k - a;
	}
	
	for(i = 0; i < k; i++){
		if(b > 0)
			b--;
		else if(c > 0){
			ans--;
			c--;
		}
	}
	
	printf("%d", ans);
			
	
	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int n;
    cin >> n;

    vector<pii> e;
    
    for(int i = 1; i <= n; i++) {
        for(int j = i + 1; j <= n; j++) {
            if(i + j == n + (n%2==0)) continue;
            e.bash(pii(min(i,j), max(i,j)));
        }
    }
    sort(ALL(e));
    e.erase(unique(ALL(e)), e.end());

    cout << e.size() << endl;

    for(auto&&p:e) {
        cout << p.first __ p.second << endl;
    }
  
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N;
long double x[100009], y[100009];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) { cin >> x[i] >> y[i]; }

	long double p1 = 0, p2 = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = i + 1; j <= N; j++) {
			long double dst = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
			dst = sqrtl(dst);
			p1 += dst;
			p2 += 1.0L;
		}
	}

	printf("%.12Lf\n", 1.0L * (1.0L * N - 1.0L) * p1 / p2);
	return 0;
}

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

int n, k, q, p[100005];

signed main(){
  
  cin>>n>>k>>q;
  
  for(int i=0;i<q;i++){
    int a;
    cin>>a;
    p[a-1]++;
  }
  
  for(int i=0;i<n;i++){
    
    int point = k - ( q - p[i] );
    
    if( point > 0 ) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
  }
  
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;
 
const ll N=2e5+10;
mat v(26);
ll n;
string s;
ll dp[N];
 
ll solve(ll cur) {
  if(cur==n) {
    return 0;
  }
  ll &ret=dp[cur];
  if(ret!=-1) {
    return ret;
  }
  ret=1e9;
  for(ll i=0;i<26;i++) {
    ll idx=upper_bound(v[i].begin(),v[i].end(),cur)-v[i].begin();
    ll nex=v[i][idx];
    ret=min(ret,solve(nex)+1);
  }
  return ret;
}
 
void build(ll cur) {
  if(cur==n) {
    return ;
  }
  for(ll i=0;i<26;i++) {
    ll idx=upper_bound(v[i].begin(),v[i].end(),cur)-v[i].begin();
    ll nex=v[i][idx];
    if(solve(cur)==solve(nex)+1) {
      cout << (char)(i+'a');
      build(nex);
      break;
    }
  }
}
 
int main() {
  memset(dp,-1,sizeof(dp));
  cin >> s;
  s="#"+s;
  n=s.size();
  for(ll i=1;i<n;i++) {
    v[s[i]-'a'].push_back(i);
  }
  for(ll i=0;i<26;i++) {
    v[i].push_back(n);
  }
  build(0);
}

Measured memory_bytes: 7400
#include<bits/stdc++.h>
#define mod 1000000007
#define mod1 998244353
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
typedef unsigned long long int ull;
using namespace std;
bool sortbysec(const pair<li,li>&a,const pair<li,li>&b)
{
    return (a.second<b.second);
}
vector<li>p;
void dfs(vector<li>v[],li visit[],li s)
{
  visit[s]=1;
  p.push_back(s+1);
  for(auto i=v[s].begin();i!=v[s].end();i++)
  {
    if(!visit[*i])
      dfs(v,visit,*i);
  }
}
int main()
{
fast_io
li n;
cin>>n;
cout<<(n/500)*1000+((n%500)/5)*5;
return 0;
}


Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let isBiparateGraph g =
        let col = Array.make (Array.length g) (-1) in
        let rec dfs cur c =
            let rec loop = function
                | [] -> true
                | hd :: tl ->
                        if col.(hd) = -1 then (
                            col.(hd) <- c;
                            if dfs hd (1 - c) then loop tl else false
                        ) else if col.(hd) = c then loop tl
                          else false
            in
            loop g.(cur)
        in
        col.(0) <- 0;
        dfs 0 1
    in

    let warshallFloyd g =
        let n = Array.length g in
        let d = Array.make_matrix n n (n + 1) in
        Array.iteri (fun i l -> List.iter (fun j -> d.(i).(j) <- 1) l) g;
        for k = 0 to n - 1 do
            for i = 0 to n - 1 do
                for j = 0 to n - 1 do
                    d.(i).(j) <- min d.(i).(j) (d.(i).(k) + d.(k).(j))
                done
            done
        done;
        d
    in

    let a = Array.make n [] in
    for i = 0 to n - 1 do
        Scanf.scanf " %s" (fun s -> 
            for j = 0 to n - 1 do
                if s.[j] = '1' then a.(j) <- i :: a.(j)
            done
        )
    done;
    Printf.printf "%d\n" @@
        if isBiparateGraph a then (
            let d = warshallFloyd a in
            1 + Array.fold_left (fun acc arr -> Array.fold_left (fun a b -> if b < n then max a b else a) acc arr) 0 d
        ) else (-1)
)

Measured memory_bytes: 1408
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
       mut p:[(i64,i64);n],
    }

    p.sort();
    for (i, v) in p.iter_mut().enumerate() {
        v.0 = (i + 1) as i64;
        swap(&mut v.0, &mut v.1);
    }
    p.sort();
    let mut l = BIT::<SUM>::new(n);
    let mut r = BIT::<SUM>::new(n);
    for i in 1..=n {
        r.add(i, &1);
    }
    let n = n as i64;
    let mut ans = n as i64 * mod_pow(2, n - 1, MOD);
    for (i, p) in p.iter().enumerate() {
        let i = i as i64;
        let y = p.1 as usize;
        r.add(y, &(-1i64));
        let a = l.sum(y);
        let b = (i - a as i64);
        let c = r.sum(y);
        let d = (n - 1 - i) - c;
        ans += mod_pow(2, n - 1, MOD)
            + mod_pow(2, a, MOD)
            + mod_pow(2, b, MOD)
            + mod_pow(2, c, MOD)
            + mod_pow(2, d, MOD)
            - mod_pow(2, a + b, MOD)
            - mod_pow(2, a + c, MOD)
            - mod_pow(2, b + d, MOD)
            - mod_pow(2, c + d, MOD)
            - 1;
        ans = (ans + MOD * 111) % MOD;
        l.add(y, &1i64);
    }
    println!("{}", ans);
}

const MOD: i64 = 998244353;
pub fn mod_pow(x: i64, n: i64, m: i64) -> i64 {
    let mut res = 1;
    let mut x = x % m;
    let mut n = n;
    while n > 0 {
        if n & 1 == 1 {
            res = (res * x) % m;
        }
        x = (x * x) % m;
        n >>= 1;
    }
    res
}
pub trait Monoid {
    type T: Clone;
    fn id() -> Self::T;
    fn op(a: &Self::T, b: &Self::T) -> Self::T;
}
pub struct SUM {}
impl Monoid for SUM {
    type T = i64;
    fn id() -> Self::T {
        0
    }
    fn op(a: &Self::T, b: &Self::T) -> Self::T {
        *a + *b
    }
}
/// Generic Binary Indexed Tree
pub struct BIT<M: Monoid> {
    buf: Vec<M::T>,
}
impl<M: Monoid> BIT<M> {
    pub fn new(n: usize) -> Self {
        Self {
            buf: vec![M::id(); n + 1],
        }
    }
    pub fn sum(&self, i: usize) -> M::T {
        let mut i = i;
        let mut s = M::id();
        while i > 0 {
            s = M::op(&s, &self.buf[i]);
            i -= 1 << i.trailing_zeros();
        }
        s
    }
    pub fn add(&mut self, i: usize, x: &M::T) {
        let mut i = i;
        while i < self.buf.len() {
            let t = &mut self.buf[i];
            *t = M::op(&t, x);
            i += 1 << i.trailing_zeros();
        }
    }
}


Measured memory_bytes: 13412
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <complex>
using namespace std;

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

typedef complex<double> P;
typedef pair<P, P> line;

#define EPS (1e-10)
#define EQ(a, b) (abs((a)-(b)) < EPS)
#define EQV(a, b) (EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()))

#define X real()
#define Y imag()

double dot(P a, P b) { return a.X*b.X+a.Y*b.Y; }
double cross(P a, P b) { return a.X*b.Y - a.Y*b.X; }

P unit_vector(P a) { return a/abs(a); }
P normal_vector1(P a) { return a * P(0, 1); }
P normal_vector2(P a) { return a * P(0, -1); }
double distance_p_p(P a, P b) { return abs(a-b); }

int is_intersected_ls(line l1, line l2)
{
	P a1 = l1.first, a2 = l1.second, b1 = l2.first, b2 = l2.second;
//printf("(%lf, %lf, %lf, %lf), (%lf, %lf, %lf, %lf)\n",
	//a1.X, a1.Y, a2.X, a2.Y, b1.X, b1.Y, b2.X, b2.Y);
	return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS )
		&& ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}

P intersection_ls(line l1, line l2)
{
	P a1 = l1.first, a2 = l1.second, b1 = l2.first, b2 = l2.second;
	P b = b2-b1;
	double d1 = abs(cross(b, a1-b1));
	double d2 = abs(cross(b, a2-b1));
	double t = d1 / (d1 + d2);

	return a1 + (a2-a1)*t;
}

bool epsfind(vector<P> ps, P a)
{
	rep(i, ps.size()) {
		P p = ps[i];
		if (EQV(p, a))
			return true;
	}
	return false;
}

int N;

int main()
{
	while (cin >> N, N) {
		vector<line> ls;

		rep(i, N) {
			double x1, y1, x2, y2;
			cin >> x1 >> y1 >> x2 >> y2;
			P p1 = P(x1, y1), p2 = P(x2, y2);
			ls.push_back(make_pair(p1, p2));
		}

		int ans = 0;
		rep(i, N) {
			line current = ls[i];
			if (i == 0) {
				ans += 2;
			} else {
				int independents_cnt = 0;
				vector<P> independents;

				rep(j, i) {
					line pre = ls[j];
					if (is_intersected_ls(current, pre)) {
						P p = intersection_ls(current, pre);
						if (EQ(p.X, -100) || EQ(p.X, 100) || EQ(p.Y, -100) || EQ(p.Y, 100))
							continue;
						if (!epsfind(independents, p)) {
							independents_cnt++;
							independents.push_back(p);
						}
					}
				}
				ans += independents_cnt+1;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1244
s = input()
if s[0] == s[-1]:
    #最終的にababa...aの場合
    if len(s) % 2 == 1:
        print("Second")
    else:
        print("First")
else:
    #最終的にababa..bの場合
    if len(s) % 2 == 0:
        print("Second")
    else:
        print("First") 

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
const double pi = 3.141592653589793;
int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    rep(i,n){
        cin>>a[i]>>b[i];
    }
    all(a);
    all(b);
    if(n%2!=0){
        cout<<b[n/2]-a[n/2]+1<<endl;
    }
    else{
        cout<<b[n/2]+b[n/2-1]-(a[n/2]+a[n/2-1])+1<<endl;
    }
}

Measured memory_bytes: 4820
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MAX 1000000000
#define MOD 1000000007
#define MOD2 998244353
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    for(int cc=1;cc<=t;cc++){
        //cout<<"Case #"<<cc<<": ";
        int n;
        cin>>n;
        int a[n],h[1000001]={0};
        for(int i=0;i<n;i++){
            cin>>a[i];
            if(h[a[i]]==0)
                h[a[i]] = i+1;
            else
                h[a[i]] = n+1;
        }
        int ans = 0;
        for(int i=0;i<n;i++){
            int root = sqrt(a[i]);
            bool flag = true;
            for(int j=1;j<=root;j++){
                if(a[i]%j==0){
                    if(h[j]>0&&h[j]!=i+1){
                        flag = false;
                        break;
                    }
                    if(h[a[i]/j]>0&&h[a[i]/j]!=i+1){
                        flag = false;
                        break;
                    }
                }
            }
            if(flag)
                ans++;
        }
        cout<<ans<<"\n";
    }
}


Measured memory_bytes: 8308
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
    int n, k;
    cin >> n >> k;
    
    vector<ll> xs(n), ys(n);
    vector<pair<ll, ll> > ps(n);
    for(int i=0; i<n; i++) {
        cin >> xs[i] >> ys[i];
        ps[i].first = xs[i];
        ps[i].second = ys[i];
    }
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());

    ll res = 2000000001LL;
    res *= res;

    for(int r=1; r<n; r++) {
        for(int l=0; l<r; l++) {
            for(int t=1; t<n; t++) {
                for(int b=0; b<t; b++) {
                    int ct = 0;
                    for(auto &p : ps) {
                        if(xs[l]<=p.first && p.first<=xs[r] && ys[b]<=p.second && p.second<=ys[t]) ct++;
                    }
                    if(ct>=k) res = min(res, (xs[r]-xs[l])*(ys[t]-ys[b]));
                }
            }
        }
    }
    
    cout << res << endl;


    return 0;
}

Measured memory_bytes: 256
X, Y = map(int, input().split())

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9 + 7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, N +1):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

if ((X + Y) % 3 != 0):
    print(0)
    exit()

A = (2 * Y - X) // 3
B = (2 * X - Y) // 3

print(cmb(A + B, A))


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

typedef long long ll;
ll N;
ll dp[3010][3010];
bool ch[3010][3010];
ll A[3010];
ll rec(ll i, ll j)
{   
    if(ch[i][j]) return dp[i][j];
    int turn = N - (j - i);
    ll res;
    if(turn == N)
    {
        res = 0;
    }
    else if(turn % 2 == 0) // first
    {
        res = max(A[i] + rec(i + 1, j), A[j - 1] + rec(i, j - 1));
    }
    else // second
    {
        res = min(rec(i + 1, j) - A[i], rec(i, j - 1) - A[j - 1]);
    }
    ch[i][j] = true;
    return dp[i][j] = res;
}

int main()
{
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    memset(dp, 0, sizeof(dp));
    //for(int i = 0; i < 3010; i++)
    //for(int j = 0; j < 3010; j++) ch[i][j] = false;
    memset(ch, 0, sizeof(ch));

    cout << rec(0, N) << endl;
}

Measured memory_bytes: 80000
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int n,m;
vector<int> v[20];
int a[20];
int ok[20];
int res=0;
int main()
{
	cin >>n>>m;
	for (int i=0;i<m;i++)
	{
		cin >>a[i];
		for (int j=0;j<a[i];j++)
		{
			int x;
			cin >>x;
			x--;
			v[i].push_back(x);
		}
	}
	for (int i=0;i<m;i++) cin >>ok[i];
	for (int t=0;t<(1<<n);t++)
	{
		//cout <<t<<" ###########\n";
		bool fl=1;
		for (int i=0;i<m;i++)
		{
			int ta=0;
			for (int j=0;j<a[i];j++) if (t & (1<<v[i][j])) ta++;
			if (ta%2!=ok[i])
			{
				fl=0;
				//cout <<i<<" "<<ta<<" ##\n";
				break;
			}
		}
		if (fl) res++;
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

string S;
signed main(){
	cin >> S;
	if(S == "AAA" || S == "BBB") cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256