jiahuimbzuai/CoQuIR huggingface dataset:
//  [rust]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const MAX: usize = 30;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let a: Vec<usize> = sc.vec(N);
    let mut cnt = vec![0; MAX];
    for i in 0..N {
        for b in 0..MAX {
            if (a[i]>>b) & 1 != 0 {
                cnt[b] += 1;
            }
        }
    }
    let mut ans = vec![0; N];
    for i in 0..N {
        for b in 0..MAX {
            if (cnt[b] - ((a[i]>>b) & 1)) % 2 != 0 {
                ans[i] |= 1<<b;
            }
        }
        println!("{}", ans[i]);
    }
}
//  [rust]
fn solve() {
    let n: usize = read();
    let mut a = vec![];
    let mut mask = 0;
    for i in 0..n {
        let v: usize = read();
        a.push(v);
        mask ^= v;
    }
    for i in 0..n {
        println!("{}", a[i] ^ mask);
    }
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========
//  [swift]
let _ = readInt()
let An = readInts()
let all = An.reduce(0, ^)
for a in An {
    print(all ^ a, terminator: " ")
}
print()

// MARK: -----------------------------------------------------------------------


func readInt() -> Int {
    Int(readLine()!)!
}

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func mapToTuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating get {
            if let note = dictionary[argument] {
                return note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                return result
            }
        }
    }
}
//  [swift]
let N = Int(readLine()!)!
var a = readLine()!.split(separator: " ").map { Int($0)! }

var sum = a.reduce(0, ^)

let res = a.map { $0 ^ sum }
           .forEach { print($0, terminator: " ") }
//  [swift]
func readIntArray() -> [Int] {
    readLine()!.split(separator: " ").map({Int($0)!})
}


let N = Int(readLine()!)!
let a = readIntArray()
var total = 0
a.forEach({
    total ^= $0
})
a.forEach({
    print(total ^ $0, terminator: " ")
})
//  [python]
N = int(input())
candy = 0
for i in range(1, N + 1):
    candy += i
print(candy)
//  [python]
N = int(input())
print (N * (N + 1) // 2)
//  [python]
import numpy as np

N = int(input())
all_list = [i for i in range(1, N+1)]
result = np.cumsum(all_list)
print(max(result))
//  [java]
import java.util.Scanner;

/**
 * Created by wild on 16/08/13.
 */
public class Main{
    public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int result = 0;
        for (int i = 0; i < n; i++){
            result += 1 + i;
        }
        System.out.println(result);
    }
}
//  [java]
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner x= new Scanner(System.in);
int num = x.nextInt();

System.out.println((1+num)*num/2);

}
}
//  [java]
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
  Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    new Main().run();
  }

  void run() {
    System.out.println(IntStream.rangeClosed(1, ni()).reduce(0, (a, b) -> a + b));
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}
//  [cpp]
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

int n;

int main() {

	cin >> n;

	int sum = 0;
	for (int i = 1; i <= n; ++i)
		sum += i;

	cout << sum << endl;

	return 0;
}
//  [cpp]
#include<bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector<int>
#define VII vector<PII>
#define VLL vector<PLL>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}

struct TT{
	LL a,b;
}tt,ss;
LL t,n,m,ans;
LL MOD=1e9+7;

int main()
{
//	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,res;
	cin>>n;
	cout<<(n+1)*n/2<<endl;
	return 0;
}
//  [cpp]
#include <cstdlib>
#include <iostream>


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

  int n;
  std::cin >> n;
  std::cout << n * (n + 1) / 2 << std::endl;

  return EXIT_SUCCESS;
}
//  [c]
#include <stdio.h>
int main(void){
    
    int a;
    int sum = 0;

    scanf("%d",&a);
    
    for(int i=1;i<=a;i++){
        sum = sum + i;
    }

    printf("%d\n",sum);
    return 0;
}
//  [c]
#include<stdio.h>
int main()
{
	int a,sum = 0;
	scanf("%d",&a); // 3
	float pembagi = 2;
	int sn = a / pembagi * (2 * 1 + (a-1) * 1);
	printf("%d\n",sn);
	return 0;
}
//  [c]
#include <stdio.h>

int main(void){
  int N, sum;
  scanf("%d", &N);
  sum = N*(N+1)/2;
  printf ("%d\n",sum);
  return 0;
}
//  [javascript]
function main(input) {
 const n = parseInt(input, 10);
  console.log(n*(1+n)/2);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(input) {
  input = input.trim();
  const a = input.split(" ").map(Number);
  let sum = 0;
  for(let i=0;i<a;++i){
     sum += (i+1);
  }
  console.log(sum);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
process.stdin.resume();
    process.stdin.setEncoding('utf8');

    process.stdin.on('data', function (chunk) {
        var numbers = chunk.toString().split(' ');
        var a = parseInt(numbers.pop());
        var c = a*(a+1)/2;

        process.stdout.write(c.toString());    

        process.exit();
    });
//  [go]
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	ans := 0
	for i := 1; i <= n; i++ {
		ans += i
	}
	fmt.Println(ans)
}
//  [go]
package main

import "fmt"

func main() {
	// Code for A - Children and Candies (ABC Edit)
	var N int
	fmt.Scanf("%d", &N)
	var ans int
	for i := 0; i < N; i++ {
		ans += i + 1
	}

	fmt.Println(ans)
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	k := 0
	for i := 1; i <= n; i++ {
		k += i
	}
	fmt.Println(k)
}
//  [ruby]
n = gets.to_i
puts n*(n+1)/2
//  [ruby]
p [*1..gets.to_i].sum
//  [ruby]
n = gets().chomp.to_i

puts (1 + n) * n / 2
//  [rust]
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        N: usize,
    }

    let ans = N * (1 + N) / 2;
    println!("{}", ans);
}
//  [rust]
use proconio::input;

fn main() {
    input! {
        n: i32
    }
    let mut v = 0;
    for i in 1..n+1 {
        v += i;
    }
    println!("{}", v);
}
//  [rust]
use proconio::fastout;
use whiteread::parse_line;

#[fastout]
fn main() {
    let n: usize = parse_line().unwrap();
    println!("{}", n * (n + 1) / 2);
}
//  [swift]
//
//  main.swift
//  Atcoder
//
//  Created by Louis Joe Shen on 2020/9/26.
//  Copyright © 2020 Louise Joe Shen. All rights reserved.
//

import Foundation

var input = readLine()!.split(separator: " ")

var N = Int(input[0])!

var sum = 0

for i in 1 ... N{
    sum += i
}

print(sum)
//  [swift]
import Foundation

let input_line = Int(readLine()!)!

// #1
var n = input_line
var count = 0
for i in 1..<n+1 {
    count += i
}

print(count)
//  [swift]
import Foundation

let a = readLine()!

let b = Int(a)!;


func kaijyo(n:Int) -> Int{
 
  if(n<0){
   
    return 0;
  }
  
  return n + kaijyo(n-1);
}

print("\(kaijyo(b))")
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = Number(input[0][0]);

  return (N * (N + 1)) / 2;
};

console.log(main(read()));
//  [typescript]
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf8");

var reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on("line", (line: string): void => {
  const num: number = parseInt(line);
  console.log(num === 1 ? 1 : num * (num + 1) / 2);
});
//  [typescript]
import * as fs from 'fs';
const input = fs.readFileSync("/dev/stdin", "utf8").split(' ');

// A- キャンディとN人の子供イージー

const N = +input[0];
let result = 0;

for (let i = 1; i <= N; i++) {
    result += i;
}

console.log(result);
//  [python]
n=int(input())
a=list(map(int,input().split()))
mini=float('inf')
sum1=0
sum2=sum(a)
t=0
while t<10**7:
	t+=1
for i in range(n):
    sum1=sum1+a[i]
    sum2=sum2-a[i]
    mini=min(mini,abs(sum1-sum2))
print(mini)
//  [python]
# -*- coding: utf-8 -*-
# IMPORT ###############################################################################################################
import sys                                                      # システム
sys.setrecursionlimit(10**6)                                    # 再帰処理の上限変更
from collections import deque, Counter                          # キュー・個数カウント
from itertools   import accumulate, permutations, combinations  # 累積和・順列・組み合わせ
from operator    import itemgetter                              # ソート補助
from bisect      import bisect_left, bisect_right, bisect       # 二分探索
from heapq       import heappop, heappush                       # プライオリティキュー
from fractions   import gcd                                     # 最大公約数
from math        import ceil, floor, sqrt, cos, sin, tan, pi    # 数学処理
from copy        import deepcopy                                # オブジェクトコピー
import numpy         as np                                      # 数値計算

# MAIN #################################################################################################################
def main():
    # Init #############################################################################################################
    im = InputManager()
    # Input ############################################################################################################
    n = im.inputSingle()
    w = im.inputMultiple(aslist=True)
    # Logic ############################################################################################################
    minimum = 9999999999
    for i in range(n - 1):
        sub = abs(sum(w[i + 1:n]) - sum(w[0:i + 1]))
        if sub < minimum:
            minimum = sub
    # Output ###########################################################################################################
    print(minimum)
    # Return ###########################################################################################################
    return

# INPUT MANAGER ########################################################################################################
class InputManager(object):
    def __init__(self):
        pass

    @staticmethod
    def inputSingle(dtype=int):
        return dtype(input())
    
    @staticmethod
    def inputMultiple(dtype=int, aslist=False):
        if aslist:
            return list(map(dtype, input().split()))
        else:
            return map(dtype, input().split())

    @staticmethod
    def input2D(h, dtype=int):
        return [list(map(dtype, input().split())) for i in range(h)]

# CALL MAIN ############################################################################################################
main()
//  [python]
n = int(input())
w = list(map(int, input().split()))
ans = []
for i in range(n):
    x = abs(sum(w[:i])-sum(w[i:]))
    ans.append(x)
print(min(ans))
//  [java]
import java.util.*;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int c = sc.nextInt();
        int w[] = new int[c];
        IntStream.range(0, c).forEach(i -> w[i] = sc.nextInt());

        OptionalInt r = IntStream.range(1, c).map(i -> {
            int s1 = Arrays.stream(w).limit(i).sum();
            int s2 = Arrays.stream(w).skip(i).sum();
            return Math.abs(s1 - s2);
        }).min();

        System.out.println(r.getAsInt());
    }
}
//  [java]
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
        }
        int s1 = 0;
        int s2 = Arrays.stream(w).sum();
        int min = Integer.MAX_VALUE;
        min = Math.min(min, Math.abs(s1 - s2));
        for (int i = 0; i < n; i++) {
            s1 += w[i];
            s2 -= w[i];
            min = Math.min(min, Math.abs(s1 - s2));
        }
        System.out.println(min);
    }
}
//  [java]
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] list = new int[N];
        for (int i = 0; i < N; i++) {
            list[i] = sc.nextInt();
        }
        int sum = IntStream.of(list).sum();
        int min = (int)10e5;
        int mid = 0;
        for(int i=1; i<N; i++) {
            int suml=0;
            for(int j=0; j<i; j++) {
                suml += list[j];
            }
            if( Math.abs(suml - (sum-suml)) < min) {
                min = Math.abs(suml - (sum-suml));
                mid = i;
            }
            
            
        }
        System.out.println(min);
    }
}
//  [cpp]
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

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

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

long long lcm(long long a, long long b)
{
	return a * b / gcd(a, b);
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	return a.second < b.second;
}


int main()
{
	int n;
	cin >> n;
	int w[100];
	int sum1 = 0;
	int sum2 = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> w[i];
		sum2 += w[i];
	}

	sum1 += w[0];
	sum2 -= w[0];
	int near = abs(sum1 - sum2);

	for (int t = 2; t <= n - 1; t++)
	{
		sum1 += w[t - 1];
		sum2 -= w[t - 1];
		if (abs(sum1 - sum2) < near)
		{
			near = abs(sum1 - sum2);
		}
	}
	cout << near;
}
//  [cpp]
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
vector<int> arr(MAXX);
void trozen()
{
    int n;
    cin>>n;
    vector<int> v1(n);
    for(auto &i:v1) cin>>i;
    int ans=INT_MAX;
    for(int i=0;i<n;i++)
    {
        int s1=0,s2=0;
        for(int k=0;k<=i;k++)
            s1+=v1[k];
        for(int k=i+1;k<n;k++)
            s2+=v1[k];
        ans=min(ans,abs(s1-s2));
    }
    cout<<ans<<endl;
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}
//  [cpp]
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n;
  cin >> n;
  std::vector<int> w(n);
  int left = 0, right = 0;
  for (int i = 0; i < n; i++) {
    cin >> w[i];
    right += w[i];
  }
  int diff = right;

  for (int i = 0; i < n; i++) {
    left += w[i];
    right -= w[i];
    int temp = std::abs(left - right);
    diff     = std::min(diff, temp);
  }
  cout << diff << endl;

  return 0;
}
//  [c]
#include<stdio.h>
int main()
{
int n,i,ans,sa1,sa2;
scanf("%d",&n);  
int w[n],sum[n];
  
  scanf("%d",&w[i]);
  sum[0]=w[0];
  
  for(i=1;i<n;++i)
  {scanf("%d",&w[i]);
  sum[i]=sum[i-1]+w[i];
  }
  
  for(i=0;sum[i]<sum[n-1]/2;++i)
  {ans=i;}
  
  sa1=sum[n-1]-sum[ans]*2;
  sa2=2*sum[ans+1]-sum[n-1];
  
  if(sa1<sa2) printf("%d",sa1);
  else printf("%d",sa2);
  
return 0;
}
//  [c]
#include <stdio.h>

int main(){
  int N,W[200],M=1000000;
  scanf("%d",&N);
  W[0]=0;
  for(int i=1;i<=N;i++){
    scanf("%d",W+i);
    W[i]+=W[i-1]; 
  }
  int S;
  for(int i=1;i<N;i++){
    S=W[N]-2*W[i];
    if(S<0) S=-S;
    if(S<M) M=S;
  }
  printf("%d\n",M);
  return 0;
}
//  [javascript]
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var w = o.l();
  var mn = 1e9;
  for(var i = 0; i < n; i++){
    var s = 0;
    for(var j = 0; j <= i; j++){
      s += w[j];
    }
    for(; j < n; j++){
      s -= w[j];
    }
    s = Math.abs(s);
    if(s < mn)mn = s;
  }
  return mn;
}
//  [javascript]
'use strict'

function Main(input) {
  const N = Number(input.split("\n")[0])
  const W = input.split("\n")[1].split(" ").map(x => Number(x))
  const list = []

  const total = W.reduce((acc, x) => acc + x)

  for(let i=1; i<N; i++) {
      let before = 0
      for(let j=0; j<i; j++) {
          before += W[j]
      }
      let after = total - before
      list.push(Math.abs(before - after))
  }
  console.log(Math.min.apply(null, list))
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim())
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    N = Number(tmp0[0])
    W = input[1].split(" ").map(str => parseInt(str, 10))
    var ans = 100000
    for(var t=1; t < N; t++){
        S1=0
        S2=0
        for(var i=1; i <= t; i++){
            S1 += W[i-1]
        }
        for(var i=t+1; i <= N; i++){
            S2 += W[i-1]
        }
        diff = Math.abs(S2-S1)
        if(ans > diff){
            ans = diff
        }
    }
    console.log(ans)
  }
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//   Main("4\n1 3 1 1");
//  [go]
package main

import (
	"fmt"
	"math"
)

func main() {

	var N int
	fmt.Scanf("%d", &N)

	W := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &W[i])
	}

	var S1, S2 int
	var min int = 10000
	for T := 1; T < N; T++ {
		S1 = 0
		S2 = 0
		for i := 0; i < T; i++ {
			S1 += W[i]
		}
		for i := N - 1; i >= T; i-- {
			S2 += W[i]
		}

		if min >= int(math.Abs(float64(S1)-float64(S2))) {
			min = int(math.Abs(float64(S1) - float64(S2)))
		}
	}

	fmt.Println(min)
}
//  [go]
package main

import (
	"fmt"
	"math"
)

func main() {

	var N int
	fmt.Scanf("%d", &N)

	var sum int = 0
	W := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &W[i])
		sum += W[i]
	}

	var S1, S2 int
	var min int = 10000
	for T := 1; T < N; T++ {

		S1 += W[T-1]
		S2 = sum - S1

		if min >= int(math.Abs(float64(S1)-float64(S2))) {
			min = int(math.Abs(float64(S1) - float64(S2)))
		}
	}

	fmt.Println(min)
}
//  [ruby]
n = gets.to_i
sum = 0
w = gets.split.map do |i|
  sum += i.to_i
  i.to_i
end
comp = 0
min = Float::INFINITY
w.each do |i|
  comp += i
  min = [min,(comp - (sum - comp).abs).abs].min
end
puts min
//  [ruby]
_,*w=`dd`.split.map(&:to_i)
min=100
sum=0
all=w.sum
w.each do |wi|
  sum+=wi
  min=[min,(sum-(all-sum)).abs].min
end
p min
//  [ruby]
n = gets.chomp.to_i
arr = gets.chomp.split(" ").map(&:to_i)

abs_arr = (1...n).map do |t|
    a1 = arr[0..t]
    a2 = arr[(t + 1)..n]
    s1 = a1.sum
    s2 = a2.sum
    (s1 - s2).abs
end

puts abs_arr.min
//  [rust]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        N: usize,
        Ws: [i64; N],
    }

    let mut ans = std::i64::MAX;
    for i in 0..N - 1 {
        let s1: i64 = Ws.iter().take(i + 1).sum();
        let s2: i64 = Ws.iter().skip(i + 1).sum();
        ans = min(ans, (s1 - s2).abs());
    }

    println!("{}", ans);
}
//  [rust]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use std::cmp::min;

#[fastout]
fn main() {
    input! {
    n: usize,
    w: [i64; n]
    }
    let mut ans = std::i64::MAX;
    for i  in 0..n {
        let t = (w[i..].iter().sum::<i64>() - w[..i].iter().sum::<i64>()).abs();
        ans = min(t, ans);
    }
    println!("{}", ans);
}
//  [rust]
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        n: usize,
        v: [i32; n],
    }
    let mut ret = 100000;
    for i in 1..n {
	let sum1: i32 = v[..i].iter().sum::<i32>();
	let sum2: i32 = v[i..].iter().sum::<i32>();
	let tmp1 = sum1 - sum2;
	let tmp2 = num::abs(tmp1);
	if tmp2 < ret {
	    ret = tmp2;
	}
    }
    println!("{}", ret)
}
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    func enumerated() -> EnumerateSequence<[Element]> {
        return self.enumerate()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}
//func gcd(x: Int, _ y: Int) -> Int {
//    if y == 0 {
//        return x
//    } else {
//        return gcd(y, x%y)
//    }
//}
//func lcm(x: Int, _ y: Int) -> Int {
//    return x * y / gcd(x, y)
//}

/*************** テストスペース ***************/

//arr.sort{$0.0==$1.0 ? $0.1<$1.1 : $0.0<$1.0}  // 2つの条件に優先順位をつけてソート

/*************** メインプログラム ***************/

let N = readInt()!
let W = readIntSplit(by: " ")
var S1 = 0
var S2 = W.reduce(0){$0+$1}
var ans = abs(S1-S2)
for i in W {
    S1 += i
    S2 -= i
    ans = min(abs(S1-S2), ans)
}
print(ans)
//  [swift]
let _ = readLine()
let W = readLine()!.characters.split(" ").map{Int(String($0))!}
var S1 = 0
var S2 = W.reduce(0){$0+$1}
var ans = S2
for i in W {
    S1 += i
    S2 -= i
    ans = min(abs(S1-S2), ans)
}
print(ans)
//  [typescript]
const main = (lines: string) => {
  const data = lines.split("\n");
  const N = parseInt(data[0]);
  const weights = data[1].split(" ").map(str => parseInt(str));
  let sumOfWeights: number;
  let calculateWeights: number = 0;
  let answer: number | null = null
  let temp: number;

  sumOfWeights = weights.reduce((a, x) => a += x, 0)

  weights.forEach(weight => {
    sumOfWeights -= weight
    calculateWeights += weight

    temp = Math.abs(sumOfWeights - calculateWeights)
    if (answer === null || answer > temp) {
      answer = temp
    }
  });

  console.log(answer)
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
const main = (lines: string) => {
  const data = lines.split("\n");
  const N = parseInt(data[0]);
  const weights = data[1].split(" ").map(str => parseInt(str));
  let S1, S2;
  let ans;


  for (let i = 1; i < N; i++) {
    let temp;
    S1 = weights.slice(0, i).reduce((a, x) => a+=x, 0)
    S2 = weights.slice(i, N).reduce((a, x) => a+=x, 0)

    temp = Math.abs(S1 - S2);

    if (ans === undefined || ans > temp) {
      ans = temp
    }
  }

  console.log(ans)
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
const main = (lines: string) => {
  const data = lines.split("\n");
  const N = parseInt(data[0]);
  const weights = data[1].split(" ").map(str => parseInt(str));
  let minSum, maxSum;
  let absArr: number[] = [];
  let answer;


  for (let i = 1; i < N; i++) {
    minSum = weights.slice(0, i).reduce((a, x) => a+=x, 0)
    maxSum = weights.slice(i, N).reduce((a, x) => a+=x, 0)

    absArr.push(Math.abs(minSum - maxSum))
  }

  absArr.reduce((a, x) => a+=x, 0)

  console.log(Math.min.apply(null, absArr))
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [python]
import numpy
s = input()
t = input()
ti = [i for i in range(len(t))]

flg = False
for i in range(len(s)):
    tmp = [t[i] for i in numpy.roll(ti, i)]
    if s == "".join(tmp):
        flg = True
        break
    
if flg:
    print("Yes")
else:
    print("No")
//  [python]
import numpy

s = list(input())
t = input()

tmp = s[:]
for i in range(len(tmp)):
    tmp = numpy.roll(tmp, 1)
    if ''.join(tmp) == t:
        print('Yes')
        exit()
print('No')
//  [python]
s = input()
t = input()

for i in range(len(s)):
    S = s[-(i+1):]+s
    if S[:len(s)] == t:
        print('Yes')
        exit()
    
print('No')
//  [java]
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class BStringRotation {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();
            String t = in.nextString();

            out.println(IntStream.range(0, s.length()).anyMatch(i -> t.equals(s.substring(i, s.length()) + s.substring(0, i))) ? "Yes" : "No");
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

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

    }
}
//  [java]
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    char[]ss = S.toCharArray();
    char[]t = T.toCharArray();

    int cou = 0;
    for(int i=0; i<S.length(); i++){
    	for(int j=0; j<T.length(); j++) {
        if(ss[i] == t[j]) {
        	if((S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j))) {
        		cou++;
        	}
        }
        }
    }
   if(cou > 0) {
		System.out.println("Yes");
   }else {
	   	System.out.println("No");
   }
}
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s1,s2;
    cin>>s1>>s2;
    int count=0;
    while (1) {
        if (s1==s2) {
            cout<<"Yes"<<endl;
            break;
        } else if (count>10000000) {
            cout<<"No"<<endl;
            break;
        } else {
            char tmp=s1.at(s1.size()-1);
            s1.erase(s1.size()-1);
            s1=tmp+s1;
            count++;
        }
    }
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
string rot1(string s)
{
    string t = s;
    int n = s.size();
    for(int i=0;i<n;++i)
        t[(i+1)%n] = s[i];
    return t;   
}
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    string s,t;
    cin>>s>>t;
    bool flg = 0;
    for(int i=0;i<=s.size()+1;++i)
    {
        if(s==t)
            flg=1;
        s = rot1(s);
    }
    if(flg)
        cout<<"Yes";
    else
        cout<<"No";
    cout<<'\n';
    return 0;
}
//  [cpp]
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
using namespace std;
int main(){
	string s, t;
	cin >> s >> t;
	if (s.size() != t.size()) {
		cout << "No" << endl;
		getchar();
		getchar();
		return 0;
	}
	int count = 0;
	for (int i = 0; i < s.size(); i++) {
		for(int j=0;j<s.size();j++){
			for (int k = 0; k + j - 1 < s.size(); k++) {
				if ((s.substr(0, i) == t.substr(j, k) && s.substr(i, s.size() - i + 1) == t.substr(0, j))||s==t) {
					cout << "Yes" << endl;
					getchar();
					getchar();
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
	getchar();
	getchar();
	return 0;
}
//  [c]
#include<stdio.h>

int main(){

int len=0,ans=0;
char S[101];
char T[101];
// fgets(S,sizeof(S),stdin);
scanf("%s",S);
scanf("%s",T);
for (int i = 0; i < 101; i++){
  len++;
  if (S[i]=='\0'){
    len--;
    break;
  }
}
int i = len-1;
while (i>=0)
{
  int k=0,match=0;
  for (int j = 0; j < len; j++){
    k = i+j;
    if (k >= len){ k-=len;}
    if(T[j]==S[k]){
      match++;
    }else{
      break;
    }
  }
  if(match == len) ans=1;
  i--;
}

ans > 0 ? puts("Yes"):puts("No");

return 0;

}
//  [c]
#include<stdio.h>
#include<string.h>

int main(void)
{
  char s[110],t[110];
  scanf("%s%s",s,t);

  int len = strlen(s);

  int i,j;
  char stmp;
  for(i=0;i<=len;i++){
    if(strcmp(s,t)==0){
      printf("Yes\n");
      return 0;
    }
    stmp = s[len-1];
    for(j=0;len-j>1;j++)
      s[len-j-1] = s[len-j-2];
    s[0] = stmp;

  }

  printf("No\n");
  return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
int main()
{   int i,j,l,lIV,c = 0;
    char str1[101];
    char str2[101];
    scanf("%s%s",&str1,&str2);
    l = strlen(str1);
    for(i=0; i<l; i++) {
        if(strcmp(str1,str2)==0) {
            c= 1;
            break;
        }
        lIV= str2[l-1];
        for(j=l-1; j>0; j--) {
            str2[j] = str2[j-1];
        }
        str2[j] = lIV;
        str2[l] = '\0';
    }
    if(c == 1 ) printf("Yes\n");
    else printf("No\n");
    return 0;
}
//  [javascript]
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	var s = input[0];
	var t = input[1];
	var x = s.length;
	var y = s;
	for(var i = 0; i < x+1; i++){
		y = y[x-1] + y.slice(0,-1);
		if(t === y){
			console.log('Yes');
			return 0;
		}
	}
	console.log('No');	
}
//  [javascript]
'use strict'

function Main(input) {
  const S = input.split('\n')[0];
  const T = input.split('\n')[1];

  const T2 = T + T;

  

  if (T2.indexOf(S) !== -1) {
    console.log('Yes');
  } else {
    console.log('No');
  }

}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [javascript]
function Main(s){
  s = s.split("\n");
  var l = s[0].length;
  if(s[0] === s[1]){console.log("Yes");return;}
  for(var i = 0; i < l; i++){
    s[0] = s[0][l-1]+s[0].slice(0,-1);
    if(s[0] === s[1]){console.log("Yes");return;}
  }
  console.log("No");
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	S := sc.Next()
	T := sc.Next()

	for i := 0; i < len(S); i++ {
		hit := true
		for j := 0; j < len(T); j++ {
			if S[(i+j)%len(T)] != T[j] {
				hit = false
				break
			}
		}
		if hit {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scan()
	t := Scan()
	ans := "No"
	for i := 0; i < len(s); i++ {
		if s[i:]+s[:i] == t {
			ans = "Yes"
		}
	}
	fmt.Println(ans)
}
//  [go]
package main

import "fmt"

func main() {
	// Code for B - String Rotation
	var S, T string
	fmt.Scanf("%s", &S)
	fmt.Scanf("%s", &T)
	var flag int = 0
	for i := 0; i < len(S); i++ {
		temp := S[len(S)-1:len(S)] + S[0:len(S)-1]
		if temp == T {
			flag = 1
			break
		} else {
			S = temp
		}
	}
	if flag == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}
//  [ruby]
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

S = gets.chomp
T = gets.chomp

ans = false
sx = S.split('')

i = 1
while i <= sx.length
  str = S[(-i)..] + S[0..(-i-1)]
  ans = true if str == T
  i += 1
end

puts ans ? 'Yes' : 'No'
//  [ruby]
s = gets.strip.to_s
t = gets.strip.to_s
cnt = 0
m = s.size
if s==t
  puts "Yes"
  exit
end
i = 1
while i < m do
  su= s[(m-i)..(m-1)]+s[0..(m-1)-i]
  if su==t
    cnt += 1
  end
  i += 1
end
if cnt>0
  puts "Yes"
else
  puts "No"
end
//  [ruby]
S = gets.chomp
T = gets.chomp

s = S.chars

S.length.times do
  c = s.shift
  s << c
  if s.join == T
    puts 'Yes'
    exit
  end
end

puts 'No'
//  [rust]
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;
use std::collections::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        s: Chars,
        t: Chars,
    }

    let mut s_1: VecDeque<char> = VecDeque::new();
    for i in 0..s.len() {
        s_1.push_back(s[i]);
    }
    for i in 0..s.len() {
        debug!(s_1);
        if s_1==t {
            println!("Yes");
            return;
        } else {
            s_1.push_front(s_1[s_1.len()-1]);
            s_1.pop_back();
        }
    }

    println!("No");

}
//  [rust]
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn solve(s: &Vec<char>, t: &Vec<char>) -> bool {
    let n = s.len();
    for i in 0..n {
        let mut flag = true;
        for j in 0..n {
            if s[j] != t[(i + j) % n] {
                flag = false;
                break;
            }
        }
        if flag {
            return true;
        }
    }
    false
}

fn main() {
    input! {
        s: String,
        t: String,
    }

    if solve(&s.chars().collect(), &t.chars().collect()) {
        println!("Yes");
    } else {
        println!("No");
    }
}